Skip to content

Commit

Permalink
[LibOS] Add SIGTERM signal to list of pending signals
Browse files Browse the repository at this point in the history
Previously, `get_all_pending_signals()` helper function did not check
for the SIGTERM signal (which has a special handling via
`g_host_injected_signal`). Syscalls like `rt_sigsuspend()` and
`rt_sigtimedwait()` use this helper function. Because of that erroneous
behavior, apps like Nginx would wait for signals on one of these
syscalls but would *not* react to SIGTERM (i.e., won't react to `kill
<app>`). This commit fixes this bug, which in turn fixes nginx and
ra-tls-nginx examples.

Signed-off-by: Dmitrii Kuvaiskii <dmitrii.kuvaiskii@intel.com>
  • Loading branch information
Dmitrii Kuvaiskii committed Jul 27, 2023
1 parent b132f90 commit 4de6aa5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CI-Examples/ra-tls-nginx/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ sleep 10
test "$(curl --insecure -s https://localhost:8000/)" = "$(cat html/index.html)"
ret=$?

kill -9 $pid
kill $pid
wait $pid

if test $ret -eq 0
then
Expand Down
5 changes: 5 additions & 0 deletions libos/src/bookkeep/libos_signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ void get_all_pending_signals(__sigset_t* set) {

__sigemptyset(set);

int host_sig = __atomic_load_n(&g_host_injected_signal, __ATOMIC_RELAXED);
if (host_sig && host_sig != 0xff) {
__sigaddset(set, host_sig);
}

if (__atomic_load_n(&current->pending_signals, __ATOMIC_ACQUIRE) == 0
&& __atomic_load_n(&g_process_pending_signals_cnt, __ATOMIC_ACQUIRE) == 0) {
return;
Expand Down

0 comments on commit 4de6aa5

Please sign in to comment.