Skip to content

Commit 1bed551

Browse files
authored
Add nproc to prlimit64 (#997)
* add nproc to prlimit64 * lint
1 parent 4e2fb7e commit 1bed551

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/rawposix/src/sys_calls.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ use std::time::Duration;
1818
use sysdefs::constants::err_const::{get_errno, handle_errno, syscall_error, Errno, VERBOSE};
1919
use sysdefs::constants::fs_const::{STDERR_FILENO, STDIN_FILENO, STDOUT_FILENO};
2020
use sysdefs::constants::lind_platform_const::{
21-
MAX_LINEAR_MEMORY_SIZE, RAWPOSIX_CAGEID, UNUSED_ARG, UNUSED_ID, UNUSED_NAME, WASMTIME_CAGEID,
21+
MAX_CAGEID, MAX_LINEAR_MEMORY_SIZE, RAWPOSIX_CAGEID, UNUSED_ARG, UNUSED_ID, UNUSED_NAME,
22+
WASMTIME_CAGEID,
2223
};
2324
use sysdefs::constants::sys_const::{
2425
DEFAULT_GID, DEFAULT_UID, EXIT_SUCCESS, ITIMER_REAL, RLIMIT_AS, RLIMIT_DATA, RLIMIT_NOFILE,
25-
RLIMIT_RSS, RLIMIT_STACK, SIGCHLD, SIGKILL, SIGSTOP, SIG_BLOCK, SIG_SETMASK, SIG_UNBLOCK,
26-
WNOHANG,
26+
RLIMIT_NPROC, RLIMIT_RSS, RLIMIT_STACK, SIGCHLD, SIGKILL, SIGSTOP, SIG_BLOCK, SIG_SETMASK,
27+
SIG_UNBLOCK, WNOHANG,
2728
};
2829
use sysdefs::data::fs_struct::{ITimerVal, Rlimit, SigactionStruct};
2930
use sysdefs::logging::lind_debug_panic;
@@ -1209,6 +1210,10 @@ pub extern "C" fn prlimit64_syscall(
12091210
old_limit.rlim_cur = MAX_LINEAR_MEMORY_SIZE as u32;
12101211
old_limit.rlim_max = MAX_LINEAR_MEMORY_SIZE as u32;
12111212
}
1213+
RLIMIT_NPROC => {
1214+
old_limit.rlim_cur = MAX_CAGEID as u32;
1215+
old_limit.rlim_max = MAX_CAGEID as u32;
1216+
}
12121217
_ => {
12131218
lind_debug_panic(&format!("prlimit64: unsupported resource {}", resource));
12141219
old_limit.rlim_cur = 0;

tests/unit-tests/file_tests/deterministic/prlimit64.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ int main(void) {
2828
return 1;
2929
}
3030

31+
ret = getrlimit(RLIMIT_NPROC, &rl);
32+
if (ret != 0 || rl.rlim_cur == 0) {
33+
printf("FAIL\n");
34+
return 1;
35+
}
36+
3137
printf("All prlimit64 tests passed\n");
3238
return 0;
3339
}

0 commit comments

Comments
 (0)