-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(main): 引入多线程读取 ctl 命名管道,用信号机制改写 service 和 task 的状态检查 (#47)
* feat: 多线程读取ctl命名管道,信号机制改写service和task的状态检查
- Loading branch information
Showing
6 changed files
with
131 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use nix::sys::signal::{self, SigHandler, Signal}; | ||
use std::sync::atomic::{AtomicBool, Ordering}; | ||
|
||
pub static SIGCHILD_SIGNAL_RECEIVED: AtomicBool = AtomicBool::new(false); | ||
|
||
extern "C" fn handle_sigchld(_: libc::c_int) { | ||
SIGCHILD_SIGNAL_RECEIVED.store(true, Ordering::SeqCst); | ||
} | ||
|
||
pub fn init_signal_handler() { | ||
unsafe { | ||
signal::signal(Signal::SIGCHLD, SigHandler::Handler(handle_sigchld)) | ||
.expect("Error setting SIGUSR1 handler"); | ||
} | ||
} |