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 prctl(2) support #601

Closed
cyphar opened this issue May 4, 2017 · 4 comments
Closed

Add prctl(2) support #601

cyphar opened this issue May 4, 2017 · 4 comments

Comments

@cyphar
Copy link

cyphar commented May 4, 2017

I'm working on an alternative container init and signal forwarder, and a nice feature would be to be able to run it as non-pid1. However, that requires being able to set PR_SET_CHILD_SUBREAPER from within Rust.

While it's possible to do this:

use libc::{prctl, PR_SET_CHILD_SUBREAPER};
unsafe { prctl(PR_SET_CHILD_SUBREAPER, 1, 0, 0); }

The unsafe is unsightly.

@Susurrus
Copy link
Contributor

Susurrus commented May 5, 2017

Indeed, it seems reasonable to add prctl(2). Would you be willing to submit a PR for this?

@cyphar
Copy link
Author

cyphar commented May 6, 2017

I'm not a very proficient user of Rust yet (I just started picking it up last weekend), but I believe that the prctl crate could be a reasonable starting point. The biggest thing that makes prctl(2) ugly and unsafe is that the arguments are sometimes read and sometimes written to by the kernel.

@Susurrus
Copy link
Contributor

Susurrus commented May 6, 2017

If you want to have a go at it, I'll mentor you. This crate does very low level abstractions, so basically what you already wrote puts you half way there I'd think. We wouldn't try to offer a more comprehensive high-level API as that crate seems to be aiming for. Otherwise I don't know how likely it is for someone to tackle this in the near future.

@SteveLauC
Copy link
Member

Close as completed in #1550

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

No branches or pull requests

3 participants