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

This commit is contained in:
Mickaël Salaün
2015-06-21 16:43:19 +02:00
parent 832e5a02cd
commit b3df1e6b48
2 changed files with 19 additions and 3 deletions

View File

@@ -36,7 +36,7 @@ pub struct Command {
pub cwd: Option<CString>,
pub uid: Option<uid_t>,
pub gid: Option<gid_t>,
pub detach: bool, // not currently exposed in std::process
pub session_leader: bool,
}
impl Command {
@@ -48,7 +48,7 @@ impl Command {
cwd: None,
uid: None,
gid: None,
detach: false,
session_leader: false,
}
}
@@ -302,7 +302,7 @@ impl Process {
fail(&mut output);
}
}
if cfg.detach {
if cfg.session_leader {
// Don't check the error of setsid because it fails if we're the
// process leader already. We just forked so it shouldn't return
// error, but ignore it anyway.