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

std: Allow to spawn a process as a session leader on UNIX #26470

Merged
merged 1 commit into from Aug 4, 2015

Conversation

Projects
None yet
5 participants
@l0kod
Copy link
Contributor

commented Jun 21, 2015

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

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented Jun 21, 2015

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.

@l0kod

This comment has been minimized.

Copy link
Contributor Author

commented Jun 21, 2015

@alexcrichton

This comment has been minimized.

Copy link
Member

commented Jun 21, 2015

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 CREATE_NEW_PROCESS_GROUP flag on windows, as it may be nice to not bundle this in a unix-only extension trait.

@alexcrichton

This comment has been minimized.

Copy link
Member

commented Jul 29, 2015

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 #[unstable] tag instead of a stable one. Could you update with that? THanks!

@l0kod l0kod force-pushed the l0kod:process-session-leader branch 2 times, most recently from df68ce8 to 743236d Aug 1, 2015

@l0kod l0kod force-pushed the l0kod:process-session-leader branch from 743236d to b3df1e6 Aug 1, 2015

@l0kod

This comment has been minimized.

Copy link
Contributor Author

commented Aug 4, 2015

Is it OK now ? I added a new feature gate "process_session_leader".

@alexcrichton

This comment has been minimized.

Copy link
Member

commented Aug 4, 2015

@bors: r+ b3df1e6

Thanks!

@bors

This comment has been minimized.

Copy link
Contributor

commented Aug 4, 2015

⌛️ Testing commit b3df1e6 with merge 6afb8f5...

bors added a commit that referenced this pull request Aug 4, 2015

Auto merge of #26470 - l0kod:process-session-leader, r=alexcrichton
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

@bors bors merged commit b3df1e6 into rust-lang:master Aug 4, 2015

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.