From 216930914583f732f07194ef9a3ba5b269bc0773 Mon Sep 17 00:00:00 2001 From: Gao feng Date: Thu, 14 Jul 2016 19:37:21 +0800 Subject: [PATCH] exec: restore sigmask of child process Signed-off-by: Gao feng --- src/exec.c | 5 +++++ src/hyper.h | 1 + src/init.c | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/src/exec.c b/src/exec.c index eaeda37..301d2fa 100644 --- a/src/exec.c +++ b/src/exec.c @@ -590,6 +590,11 @@ out: // do the exec, no return void hyper_exec_process(struct hyper_exec *exec) { + if (sigprocmask(SIG_SETMASK, &orig_mask, NULL) < 0) { + perror("sigprocmask restore mask failed"); + goto exit; + } + if (exec->workdir && chdir(exec->workdir) < 0) { perror("change work directory failed"); goto exit; diff --git a/src/hyper.h b/src/hyper.h index 86f1b69..8448670 100644 --- a/src/hyper.h +++ b/src/hyper.h @@ -126,4 +126,5 @@ void hyper_cleanup_pod(struct hyper_pod *pod); extern struct hyper_pod global_pod; extern struct hyper_ctl ctl; +extern sigset_t orig_mask; #endif diff --git a/src/init.c b/src/init.c index 906a35d..d0ede87 100644 --- a/src/init.c +++ b/src/init.c @@ -37,6 +37,8 @@ struct hyper_pod global_pod = { struct hyper_ctl ctl; +sigset_t orig_mask; + static int hyper_handle_exit(struct hyper_pod *pod); static int hyper_stop_pod(struct hyper_pod *pod); @@ -1120,6 +1122,8 @@ static int hyper_loop(void) perror("sigprocmask SIGCHLD failed"); return -1; } + // need original mask to restore sigmask of child processes + orig_mask = omask; sigdelset(&omask, SIGCHLD); signal(SIGCHLD, hyper_init_sigchld);