Skip to content

Commit

Permalink
Handle SIGTSTP in linux threadlock (#94)
Browse files Browse the repository at this point in the history
If the a process was already stopped (for instance by hitting control-z),
we used to be able to still treat it as locked - but with recent
changes to use ptrace seize/interrupt, this no longer worked.

Fix by handling SIGTSTP.
  • Loading branch information
benfred authored Oct 28, 2024
1 parent 1595830 commit 0408ee5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,11 @@ impl ThreadLock {
Some(wait::WaitPidFlag::WSTOPPED | wait::WaitPidFlag::__WALL),
)? {
// We only really expect to see a `PTRACE_EVENT_STOP`.
wait::WaitStatus::PtraceEvent(_, nix::sys::signal::Signal::SIGTRAP, event)
if event == ptrace::Event::PTRACE_EVENT_STOP as i32 =>
{
break
}
wait::WaitStatus::PtraceEvent(
_,
nix::sys::signal::Signal::SIGTRAP | nix::sys::signal::Signal::SIGTSTP,
event,
) if event == ptrace::Event::PTRACE_EVENT_STOP as i32 => break,
// However, experimentally, it appears we see an exit status when
// a process is dying.
wait::WaitStatus::Exited(_, _) => break,
Expand Down

0 comments on commit 0408ee5

Please sign in to comment.