| ... | @@ -693,7 +693,19 @@ test "getrlimit and setrlimit" { | ... | @@ -693,7 +693,19 @@ test "getrlimit and setrlimit" { |
| 693 | inline for (std.meta.fields(os.rlimit_resource)) |field| { | 693 | inline for (std.meta.fields(os.rlimit_resource)) |field| { |
| 694 | const resource = @intToEnum(os.rlimit_resource, field.value); | 694 | const resource = @intToEnum(os.rlimit_resource, field.value); |
| 695 | const limit = try os.getrlimit(resource); | 695 | const limit = try os.getrlimit(resource); |
| 696 | try os.setrlimit(resource, limit); | 696 | |
| | 697 | // On 32 bit MIPS musl includes a fix which changes limits greater than -1UL/2 to RLIM_INFINITY. |
| | 698 | // See http://git.musl-libc.org/cgit/musl/commit/src/misc/getrlimit.c?id=8258014fd1e34e942a549c88c7e022a00445c352 |
| | 699 | // |
| | 700 | // This happens for example if RLIMIT_MEMLOCK is bigger than ~2GiB. |
| | 701 | // In that case the following the limit would be RLIM_INFINITY and the following setrlimit fails with EPERM. |
| | 702 | if (comptime builtin.cpu.arch.isMIPS() and builtin.link_libc) { |
| | 703 | if (limit.cur != os.linux.RLIM.INFINITY) { |
| | 704 | try os.setrlimit(resource, limit); |
| | 705 | } |
| | 706 | } else { |
| | 707 | try os.setrlimit(resource, limit); |
| | 708 | } |
| 697 | } | 709 | } |
| 698 | } | 710 | } |
| 699 | | 711 | |