Skip to content

Commit

Permalink
linux: reset all signal handlers to default
Browse files Browse the repository at this point in the history
Closes: containers#230

Signed-off-by: Giuseppe Scrivano <[email protected]>
  • Loading branch information
giuseppe committed Jan 29, 2020
1 parent 784fbfa commit c8843cd
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/libcrun/container.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include <sys/epoll.h>
#include <sys/socket.h>
#include <grp.h>
#include "sig2str.h"

#ifdef HAVE_SYSTEMD
# include <systemd/sd-daemon.h>
Expand Down Expand Up @@ -434,12 +435,24 @@ int block_signals (libcrun_error_t *err)
static
int unblock_signals (libcrun_error_t *err)
{
int i;
int ret;
sigset_t mask;
struct sigaction act;

sigfillset (&mask);
ret = sigprocmask (SIG_UNBLOCK, &mask, NULL);
if (UNLIKELY (ret < 0))
return crun_make_error (err, errno, "sigprocmask");

act.sa_handler = SIG_DFL;
for (i = 0; i < SIGNUM_BOUND; i++)
{
ret = sigaction (i, &act, NULL);
if (ret < 0 && errno != EINVAL)
return crun_make_error (err, errno, "sigaction");
}

return 0;
}

Expand Down

0 comments on commit c8843cd

Please sign in to comment.