Trait std::os::unix::prelude::CommandExt [] [src]

pub trait CommandExt {
    fn uid(&mut self, id: uid_t) -> &mut Command;
    fn gid(&mut self, id: gid_t) -> &mut Command;
    fn session_leader(&mut self, on: bool) -> &mut Command;
}

Unix-specific extensions to the std::process::Command builder

Required Methods

fn uid(&mut self, id: uid_t) -> &mut Command

Sets the child process's user id. This translates to a setuid call in the child process. Failure in the setuid call will cause the spawn to fail.

fn gid(&mut self, id: gid_t) -> &mut Command

Similar to uid, but sets the group id of the child process. This has the same semantics as the uid field.

fn session_leader(&mut self, on: bool) -> &mut Command

Unstable (process_session_leader #27811)

: recently added

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 achieve this, a session leader (the child) must spawn another process (the daemon) in the same session.

Implementors