43
43
//! }
44
44
//! ```
45
45
46
- mod error;
46
+ pub mod error;
47
47
48
48
extern crate libc;
49
49
@@ -340,7 +340,9 @@ impl<T> Daemonize<T> {
340
340
/// result to the child.
341
341
pub fn start ( self ) -> Result < T , Error > {
342
342
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) ,
344
346
Outcome :: Parent ( Err ( err) ) => Err ( err) ,
345
347
Outcome :: Child ( Ok ( child) ) => Ok ( child. privileged_action_result ) ,
346
348
Outcome :: Child ( Err ( err) ) => Err ( err) ,
@@ -351,12 +353,12 @@ impl<T> Daemonize<T> {
351
353
pub fn execute ( self ) -> Outcome < T > {
352
354
unsafe {
353
355
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
+ } ) ,
360
362
Err ( err) => Outcome :: Parent ( Err ( err. into ( ) ) ) ,
361
363
Ok ( None ) => match self . execute_child ( ) {
362
364
Ok ( privileged_action_result) => Outcome :: Child ( Ok ( Child {
@@ -441,10 +443,10 @@ unsafe fn perform_fork() -> Result<Option<libc::pid_t>, ErrorKind> {
441
443
}
442
444
443
445
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
+ }
448
450
449
451
unsafe fn set_sid ( ) -> Result < ( ) , ErrorKind > {
450
452
check_err ( libc:: setsid ( ) , ErrorKind :: DetachSession ) ?;
0 commit comments