[][src]Struct daemonize::Daemonize

pub struct Daemonize<T> { /* fields omitted */ }

Daemonization options.

Fork the process in the background, disassociate from its process group and the control terminal. Change umask value to 0o027, redirect all standard streams to /dev/null. Change working directory to / or provided value.

Optionally:

  • maintain and lock the pid-file;
  • drop user privileges;
  • drop group privileges;
  • change root directory;
  • change the pid-file ownership to provided user (and/or) group;
  • execute any provided action just before dropping privileges.

Methods

impl Daemonize<()>[src]

pub fn new() -> Self[src]

impl<T> Daemonize<T>[src]

pub fn pid_file<F: AsRef<Path>>(self, path: F) -> Self[src]

Create pid-file at path, lock it exclusive and write daemon pid.

pub fn chown_pid_file(self, chown: bool) -> Self[src]

If chown is true, daemonize will change the pid-file ownership, if user or group are provided

pub fn working_directory<F: AsRef<Path>>(self, path: F) -> Self[src]

Change working directory to path or / by default.

pub fn user<U: Into<User>>(self, user: U) -> Self[src]

Drop privileges to user.

pub fn group<G: Into<Group>>(self, group: G) -> Self[src]

Drop privileges to group.

pub fn umask(self, mask: mode_t) -> Self[src]

Change umask to mask or 0o027 by default.

pub fn chroot<F: AsRef<Path>>(self, path: F) -> Self[src]

Change root to path

pub fn privileged_action<N, F: FnOnce() -> N + 'static>(
    self,
    action: F
) -> Daemonize<N>
[src]

Execute action just before dropping privileges. Most common usecase is to open listening socket. Result of action execution will be returned by start method.

pub fn exit_action<F: FnOnce() + 'static>(self, action: F) -> Daemonize<T>[src]

Execute action just before exiting the parent process. Most common usecase is to synchronize with forked processes.

pub fn stdout<S: Into<Stdio>>(self, stdio: S) -> Self[src]

Configuration for the child process's standard output stream.

pub fn stderr<S: Into<Stdio>>(self, stdio: S) -> Self[src]

Configuration for the child process's standard error stream.

pub fn start(self) -> Result<T, DaemonizeError>[src]

Start daemonization process.

Trait Implementations

impl<T> Debug for Daemonize<T>[src]

Auto Trait Implementations

impl<T> !Send for Daemonize<T>

impl<T> !Sync for Daemonize<T>

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.