Skip to content

Commit 2a3d939

Browse files
committed
Make error mod public
1 parent 8a87c0b commit 2a3d939

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

daemonize/src/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pub type Errno = libc::c_int;
33
/// This error type for `Daemonize` `start` method.
44
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone)]
55
pub struct Error {
6-
kind: ErrorKind,
6+
pub kind: ErrorKind,
77
}
88

99
/// This error type for `Daemonize` `start` method.

daemonize/src/lib.rs

+14-12
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
//! }
4444
//! ```
4545
46-
mod error;
46+
pub mod error;
4747

4848
extern crate libc;
4949

@@ -340,7 +340,9 @@ impl<T> Daemonize<T> {
340340
/// result to the child.
341341
pub fn start(self) -> Result<T, Error> {
342342
match self.execute() {
343-
Outcome::Parent(Ok(Parent { first_child_exit_code })) => exit(first_child_exit_code),
343+
Outcome::Parent(Ok(Parent {
344+
first_child_exit_code,
345+
})) => exit(first_child_exit_code),
344346
Outcome::Parent(Err(err)) => Err(err),
345347
Outcome::Child(Ok(child)) => Ok(child.privileged_action_result),
346348
Outcome::Child(Err(err)) => Err(err),
@@ -351,12 +353,12 @@ impl<T> Daemonize<T> {
351353
pub fn execute(self) -> Outcome<T> {
352354
unsafe {
353355
match perform_fork() {
354-
Ok(Some(first_child_pid)) => {
355-
Outcome::Parent(match waitpid(first_child_pid) {
356-
Err(err) => Err(err.into()),
357-
Ok(first_child_exit_code) => Ok(Parent { first_child_exit_code: first_child_exit_code as i32 }),
358-
})
359-
},
356+
Ok(Some(first_child_pid)) => Outcome::Parent(match waitpid(first_child_pid) {
357+
Err(err) => Err(err.into()),
358+
Ok(first_child_exit_code) => Ok(Parent {
359+
first_child_exit_code: first_child_exit_code as i32,
360+
}),
361+
}),
360362
Err(err) => Outcome::Parent(Err(err.into())),
361363
Ok(None) => match self.execute_child() {
362364
Ok(privileged_action_result) => Outcome::Child(Ok(Child {
@@ -441,10 +443,10 @@ unsafe fn perform_fork() -> Result<Option<libc::pid_t>, ErrorKind> {
441443
}
442444

443445
unsafe fn waitpid(pid: libc::pid_t) -> Result<libc::c_int, ErrorKind> {
444-
let mut child_ret = 0;
445-
check_err(libc::waitpid(pid, &mut child_ret, 0), ErrorKind::Wait)?;
446-
Ok(child_ret)
447-
}
446+
let mut child_ret = 0;
447+
check_err(libc::waitpid(pid, &mut child_ret, 0), ErrorKind::Wait)?;
448+
Ok(child_ret)
449+
}
448450

449451
unsafe fn set_sid() -> Result<(), ErrorKind> {
450452
check_err(libc::setsid(), ErrorKind::DetachSession)?;

0 commit comments

Comments
 (0)