-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
std: Allow to spawn a process as a session leader on UNIX #26470
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @pcwalton (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
cc @aturon |
I don't believe that we want to insta-stabilize this method, but I think it's fine to expose the functionality. I'd also prefer to see if there's a cross-platform interpretation with the |
Sorry for the delay @l0kod, but the libs team convened this week and decided that we'd like to move forward on this, but with an |
df68ce8
to
743236d
Compare
743236d
to
b3df1e6
Compare
Is it OK now ? I added a new feature gate "process_session_leader". |
Add a new method `CommandExt::session_leader(&mut self, on: bool)` to create a new session (cf. `setsid(2)`) for the child process. This means that the child is the leader of a new process group. The parent process remains the child reaper of the new process. This is not enough to create a daemon process. The *init* process should be the child reaper of a daemon. This can be achieved if the parent process exit. Moreover, a daemon should not have a controlling terminal. To acheive this, a session leader (the child) must spawn another process (the daemon) in the same session. cc rust-lang/rfcs#941 cc #17176
Add a new method
CommandExt::session_leader(&mut self, on: bool)
to create a new session (cf.setsid(2)
) for the child process. This means that the child is the leader of a new process group. The parent process remains the child reaper of the new process.This is not enough to create a daemon process. The init process should be the child reaper of a daemon. This can be achieved if the parent process exit. Moreover, a daemon should not have a controlling terminal. To acheive this, a session leader (the child) must spawn another process (the daemon) in the same session.
cc rust-lang/rfcs#941
cc #17176