Skip to content

Commit

Permalink
Merge pull request #78 from r00ster91/patch-1
Browse files Browse the repository at this point in the history
termination: Check for SIGHUP
  • Loading branch information
Detegr authored Jun 10, 2021
2 parents 110bb69 + 18da399 commit aad1cbf
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/platform/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,27 @@ pub unsafe fn init_os_handler() -> Result<(), Error> {
signal::SigSet::empty(),
);

let _old = match signal::sigaction(signal::Signal::SIGINT, &new_action) {
let sigint_old = match signal::sigaction(signal::Signal::SIGINT, &new_action) {
Ok(old) => old,
Err(e) => return Err(close_pipe(e)),
};

#[cfg(feature = "termination")]
match signal::sigaction(signal::Signal::SIGTERM, &new_action) {
Ok(_) => {}
Err(e) => {
signal::sigaction(signal::Signal::SIGINT, &_old).unwrap();
return Err(close_pipe(e));
{
let sigterm_old = match signal::sigaction(signal::Signal::SIGTERM, &new_action) {
Ok(old) => old,
Err(e) => {
signal::sigaction(signal::Signal::SIGINT, &sigint_old).unwrap();
return Err(close_pipe(e));
}
};
match signal::sigaction(signal::Signal::SIGHUP, &new_action) {
Ok(_) => {}
Err(e) => {
signal::sigaction(signal::Signal::SIGINT, &sigint_old).unwrap();
signal::sigaction(signal::Signal::SIGTERM, &sigterm_old).unwrap();
return Err(close_pipe(e));
}
}
}

Expand Down

0 comments on commit aad1cbf

Please sign in to comment.