diff options
| author | Mickaël Salaün <mic@digikod.net> | 2015-06-21 16:43:19 +0200 |
|---|---|---|
| committer | Mickaël Salaün <mic@digikod.net> | 2015-08-01 19:28:00 +0200 |
| commit | b3df1e6b4812d8eefc4e7fdf61264aad15af719c (patch) | |
| tree | 26dad124649ab708467885dd36ae6198dd5f6f36 /src/libstd/sys/unix/ext/process.rs | |
| parent | 832e5a02cd41b3a20d1142b47867da4aa5033f03 (diff) | |
| download | rust-b3df1e6b4812d8eefc4e7fdf61264aad15af719c.tar.gz rust-b3df1e6b4812d8eefc4e7fdf61264aad15af719c.zip | |
std: Allow to spawn a process as a session leader on UNIX
Diffstat (limited to 'src/libstd/sys/unix/ext/process.rs')
| -rw-r--r-- | src/libstd/sys/unix/ext/process.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libstd/sys/unix/ext/process.rs b/src/libstd/sys/unix/ext/process.rs index 63adae17581..06c5261bb42 100644 --- a/src/libstd/sys/unix/ext/process.rs +++ b/src/libstd/sys/unix/ext/process.rs @@ -32,6 +32,17 @@ pub trait CommandExt { /// the same semantics as the `uid` field. #[stable(feature = "rust1", since = "1.0.0")] fn gid(&mut self, id: gid_t) -> &mut process::Command; + + /// 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. + #[unstable(feature = "process_session_leader", reason = "recently added")] + fn session_leader(&mut self, on: bool) -> &mut process::Command; } #[stable(feature = "rust1", since = "1.0.0")] @@ -45,6 +56,11 @@ impl CommandExt for process::Command { self.as_inner_mut().gid = Some(id); self } + + fn session_leader(&mut self, on: bool) -> &mut process::Command { + self.as_inner_mut().session_leader = on; + self + } } /// Unix-specific extensions to `std::process::ExitStatus` |
