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. fprintfand friends using theFILEAPI 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
working_folder_path: PathBuf
The folder path to use as the 'current working directory' (CWD).
Equivalent functionality to the shell command chdir.
Defaults to /.
pid_folder_path: PathBuf
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.
user_name: CString
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]
impl Daemonizepub fn daemonize(self) -> DaemonizeCleanUpOnExit[src]
pub fn daemonize(self) -> DaemonizeCleanUpOnExitDaemonizes 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]
impl Debug for Daemonizefn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl Clone for Daemonize[src]
impl Clone for Daemonizefn clone(&self) -> Daemonize[src]
fn clone(&self) -> DaemonizeReturns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl Ord for Daemonize[src]
impl Ord for Daemonizefn cmp(&self, other: &Daemonize) -> Ordering[src]
fn cmp(&self, other: &Daemonize) -> OrderingThis method returns an Ordering between self and other. Read more
fn max(self, other: Self) -> Self1.21.0[src]
fn max(self, other: Self) -> SelfCompares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self1.21.0[src]
fn min(self, other: Self) -> SelfCompares and returns the minimum of two values. Read more
impl PartialOrd for Daemonize[src]
impl PartialOrd for Daemonizefn partial_cmp(&self, other: &Daemonize) -> Option<Ordering>[src]
fn partial_cmp(&self, other: &Daemonize) -> Option<Ordering>This method returns an ordering between self and other values if one exists. Read more
fn lt(&self, other: &Daemonize) -> bool[src]
fn lt(&self, other: &Daemonize) -> boolThis method tests less than (for self and other) and is used by the < operator. Read more
fn le(&self, other: &Daemonize) -> bool[src]
fn le(&self, other: &Daemonize) -> boolThis method tests less than or equal to (for self and other) and is used by the <= operator. Read more
fn gt(&self, other: &Daemonize) -> bool[src]
fn gt(&self, other: &Daemonize) -> boolThis method tests greater than (for self and other) and is used by the > operator. Read more
fn ge(&self, other: &Daemonize) -> bool[src]
fn ge(&self, other: &Daemonize) -> boolThis 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 Eq for Daemonizeimpl PartialEq for Daemonize[src]
impl PartialEq for Daemonizefn eq(&self, other: &Daemonize) -> bool[src]
fn eq(&self, other: &Daemonize) -> boolThis method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Daemonize) -> bool[src]
fn ne(&self, other: &Daemonize) -> boolThis method tests for !=.
impl Hash for Daemonize[src]
impl Hash for Daemonizefn hash<__H: Hasher>(&self, state: &mut __H)[src]
fn hash<__H: Hasher>(&self, state: &mut __H)Feeds this value into the given [Hasher]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, Feeds a slice of this type into the given [Hasher]. Read more
impl Default for Daemonize[src]
impl Default for Daemonize