tree-wide: whenever we fork off a foreign child process reset signal mask/handlers

Also, when the child is potentially long-running make sure to set a
death signal.

Also, ignore the result of the reset operations explicitly by casting
them to (void).
This commit is contained in:
Lennart Poettering
2015-06-10 01:28:58 +02:00
parent 0c2c2a3aeb
commit ce30c8dcb4
26 changed files with 98 additions and 37 deletions
+2 -2
View File
@@ -109,8 +109,8 @@ static int setup_machine_raw(uint64_t size, sd_bus_error *error) {
/* Child */
reset_all_signal_handlers();
reset_signal_mask();
(void) reset_all_signal_handlers();
(void) reset_signal_mask();
assert_se(prctl(PR_SET_PDEATHSIG, SIGTERM) == 0);
fd = safe_close(fd);
+8
View File
@@ -30,6 +30,7 @@
#include "process-util.h"
#include "macro.h"
#include "terminal-util.h"
#include "signal-util.h"
static pid_t pager_pid = 0;
@@ -85,6 +86,9 @@ int pager_open(bool jump_to_end) {
if (pager_pid == 0) {
const char* less_opts;
(void) reset_all_signal_handlers();
(void) reset_signal_mask();
dup2(fd[0], STDIN_FILENO);
safe_close_pair(fd);
@@ -178,6 +182,10 @@ int show_man_page(const char *desc, bool null_stdio) {
if (pid == 0) {
/* Child */
(void) reset_all_signal_handlers();
(void) reset_signal_mask();
if (null_stdio) {
r = make_null_stdio();
if (r < 0) {
+1 -1
View File
@@ -239,7 +239,7 @@ int pty_setup_child(Pty *pty) {
assert_return(pty_is_child(pty), -EINVAL);
assert_return(pty_is_open(pty), -EALREADY);
r = sigprocmask_many(SIG_SETMASK, -1);
r = reset_signal_mask();
if (r < 0)
return r;
+4 -4
View File
@@ -2301,8 +2301,8 @@ static int do_execute(char **directories, usec_t timeout, char *argv[]) {
/* We fork this all off from a child process so that we can
* somewhat cleanly make use of SIGALRM to set a time limit */
reset_all_signal_handlers();
reset_signal_mask();
(void) reset_all_signal_handlers();
(void) reset_signal_mask();
assert_se(prctl(PR_SET_PDEATHSIG, SIGTERM) == 0);
@@ -3344,8 +3344,8 @@ int fork_agent(pid_t *pid, const int except[], unsigned n_except, const char *pa
/* Make sure we actually can kill the agent, if we need to, in
* case somebody invoked us from a shell script that trapped
* SIGTERM or so... */
reset_all_signal_handlers();
reset_signal_mask();
(void) reset_all_signal_handlers();
(void) reset_signal_mask();
/* Check whether our parent died before we were able
* to set the death signal and unblock the signals */