Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for rlimits #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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