Skip to content

Commit

Permalink
Forward signals to tracee
Browse files Browse the repository at this point in the history
  • Loading branch information
i-ky committed Mar 7, 2023
1 parent dfdcd49 commit 65947b6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/basset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,9 @@ int main(int argc, char *argv[]) {
} else if (WIFSTOPPED(wstatus)) {
verbose &&cerr << pid << " stopped\n";

if (WSTOPSIG(wstatus) == SIGTRAP) {
auto signal = WSTOPSIG(wstatus);

if (signal == SIGTRAP) {
switch (wstatus >> 16) {
case PTRACE_EVENT_EXEC: {
char exe[PATH_MAX];
Expand Down Expand Up @@ -365,11 +367,13 @@ int main(int argc, char *argv[]) {
cerr << "unknown stop event, signal: " << (wstatus >> 16) << '\n';
return -1;
}

signal = 0;
} else {
verbose &&cerr << "got signal: " << WSTOPSIG(wstatus) << '\n';
verbose &&cerr << "got signal: " << signal << '\n';
}

if (ptrace(PTRACE_CONT, pid, nullptr, nullptr) == -1) {
if (ptrace(PTRACE_CONT, pid, nullptr, signal) == -1) {
perror("cannot ptrace(PTRACE_CONT)");
return -1;
}
Expand Down

0 comments on commit 65947b6

Please sign in to comment.