Skip to content

Commit

Permalink
signal: tag user handler thread as an application one
Browse files Browse the repository at this point in the history
Signed-off-by: Waldemar Kozaczuk <[email protected]>
  • Loading branch information
wkozaczuk committed Jul 2, 2019
1 parent 0dd2ce0 commit 33bea60
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion libc/signal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,9 @@ int kill(pid_t pid, int sig)
// very Unix-like behavior, but if we assume that the program doesn't
// care which of its threads handle the signal - why not just create
// a completely new thread and run it there...
// The newly created thread is tagged as an application one
// to make sure that user provided signal handler code has access to all
// the features like syscall stack which matters for Golang apps
const auto sa = signal_actions[sig];
auto t = sched::thread::make([=] {
if (sa.sa_flags & SA_RESETHAND) {
Expand All @@ -357,7 +360,8 @@ int kill(pid_t pid, int sig)
} else {
sa.sa_handler(sig);
}
}, sched::thread::attr().detached().stack(65536).name("signal_handler"));
}, sched::thread::attr().detached().stack(65536).name("signal_handler"),
false, true);
t->start();
}
return 0;
Expand Down

0 comments on commit 33bea60

Please sign in to comment.