Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions daemonize/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,16 +374,16 @@ impl<T> Daemonize<T> {
set_sid()?;
libc::umask(self.umask.inner);

if perform_fork()?.is_some() {
exit(0)
};

let pid_file_fd = self
.pid_file
.clone()
.map(|pid_file| create_pid_file(pid_file))
.transpose()?;

if perform_fork()?.is_some() {
exit(0)
};

redirect_standard_streams(self.stdin, self.stdout, self.stderr)?;

let uid = self.user.map(|user| get_user(user)).transpose()?;
Expand Down Expand Up @@ -441,9 +441,9 @@ unsafe fn perform_fork() -> Result<Option<libc::pid_t>, ErrorKind> {
}

unsafe fn waitpid(pid: libc::pid_t) -> Result<libc::c_int, ErrorKind> {
let mut child_ret = 0;
check_err(libc::waitpid(pid, &mut child_ret, 0), ErrorKind::Wait)?;
Ok(child_ret)
let mut child_stat = 0;
check_err(libc::waitpid(pid, &mut child_stat, 0), ErrorKind::Wait)?;
Ok(libc::WEXITSTATUS(child_stat))
}

unsafe fn set_sid() -> Result<(), ErrorKind> {
Expand Down