fix: instant toggle exit via SIGUSR1 poll interruption
Remove SA_RESTART from the signal handler so SIGUSR1 interrupts the blocking poll() call with EINTR. Handle EINTR gracefully in the event loop to check should_exit() immediately instead of waiting for timeout.
This commit is contained in:
2 files changed
+13
-2
No files matched your search
+3
-1
@@ -73,9 +73,11 @@ pub fn create_lock() -> Result<LockGuard> {
|
||||
let path = lock_file_path();
|
||||
|
||||
// Install SIGUSR1 handler before writing the lock file.
|
||||
// No SA_RESTART — let the signal interrupt poll() so the event loop
|
||||
// notices should_exit() promptly instead of waiting for the timeout.
|
||||
let action = SigAction::new(
|
||||
SigHandler::Handler(handle_sigusr1),
|
||||
SaFlags::SA_RESTART,
|
||||
SaFlags::empty(),
|
||||
SigSet::empty(),
|
||||
);
|
||||
unsafe { signal::sigaction(Signal::SIGUSR1, &action) }.context("install SIGUSR1 handler")?;
|
||||
|
||||
Reference in new issue
Block a user