Struct dpdk_unix::Daemonize[][src]

pub struct Daemonize {
    pub working_folder_path: PathBuf,
    pub pid_folder_path: PathBuf,
    pub user_name: CString,
}

An object that can be used with a configuration file (eg via Serde) to configure a daemon.

The following are done:-

  • umask is set to just the current user
  • Checks are made to check the program is not running with the set uid bit set ('setuid' or 'suid').
  • A PID file is created
  • standard in is redirected to /dev/null.
  • standard out and error are redirected to /dev/null.
  • fprintf and friends using the FILE API are redirected to syslog on Linux (this is probably also possible to implement for FreeBSD - see https://mischasan.wordpress.com/2011/05/25/redirecting-stderr-to-syslog/).
  • Double forking and a new session are created.
  • Real and effective user and group ids are changed.
  • Additional groups from /etc/group, if any, are assigned.
  • Environment variables are populated if missing (IFS, PATH)
  • User environment variables are overwritten (HOME, LOGNAME, USER).

Fields

The folder path to use as the 'current working directory' (CWD).

Equivalent functionality to the shell command chdir.

Defaults to /.

A folder path in which to put a PID file.

This uses the processes' name for the actual file base name.

Defaults to /var/run.

An user name that must exist in /etc/passwd (or the local equivalent).

Use to discover runtime user and groups to change to and the home folder of the running user.

Methods

impl Daemonize
[src]

Daemonizes the current process.

Returns an object that needs to have clean_up() called on it just before process exit.

Trait Implementations

impl Debug for Daemonize
[src]

Formats the value using the given formatter. Read more

impl Clone for Daemonize
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Ord for Daemonize
[src]

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

impl PartialOrd for Daemonize
[src]

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Eq for Daemonize
[src]

impl PartialEq for Daemonize
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Hash for Daemonize
[src]

Feeds this value into the given [Hasher]. Read more

Feeds a slice of this type into the given [Hasher]. Read more

impl Default for Daemonize
[src]

Returns the "default value" for a type. Read more

Auto Trait Implementations

impl Send for Daemonize

impl Sync for Daemonize