Skip to content

Conversation

MarkusBauer
Copy link

This PR adds resource constraints to the child process, using setrlimit.

Example usage:

use nix::libc::{RLIMIT_AS, RLIMIT_CPU, RLIMIT_NICE, RLIMIT_NOFILE, RLIMIT_NPROC, RLIMIT_RSS};

cmd.set_rlimit(RLIMIT_NOFILE, 10);
cmd.set_rlimit(RLIMIT_CPU, 1);
cmd.set_rlimit(RLIMIT_NPROC, 3);
cmd.set_rlimit(RLIMIT_AS, 64 * 1024 * 1024);
cmd.set_rlimit(RLIMIT_RSS, 64 * 1024 * 1024);
cmd.set_rlimit(RLIMIT_NICE, 0);

Availability: If anyone wants to use this and other features before it's merged, check out my temporary fork. It includes #23 #27 #29 #33 #34 #35 and #36 with all conflicts resolved.
Add to your Cargo.toml: unshare = { git = "https://github.com/MarkusBauer/unshare.git" }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant