Skip to content

Commit

Permalink
Extract signal block function and make it public
Browse files Browse the repository at this point in the history
  • Loading branch information
cbranch authored and vkrasnov committed Jun 16, 2020
1 parent 86195ea commit feb1d25
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/device/epoll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,3 +382,17 @@ impl<'a, H> EventGuard<'a, H> {
std::mem::forget(self); // Don't call the regular drop that would enable the event
}
}

pub fn block_signal(signal: c_int) -> Result<sigset_t, String> {
unsafe {
let mut sigset = std::mem::zeroed();
sigemptyset(&mut sigset);
if sigaddset(&mut sigset, signal) == -1 {
return Err(errno_str());
}
if sigprocmask(SIG_BLOCK, &sigset, null_mut()) == -1 {
return Err(errno_str());
}
Ok(sigset)
}
}

0 comments on commit feb1d25

Please sign in to comment.