X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fexecute.c;h=1b37f2efe45c122b0b7a7c9aecb515318f2ca998;hp=53f6d9ad06dcaf8169ef825278bae2753ebaae46;hb=9a57a1fdd6491bb319d5ae59b505fa224b873ccf;hpb=ff876e283a61320b718ec752d93b1fd40a5fdd0c diff --git a/src/execute.c b/src/execute.c index 53f6d9ad0..1b37f2efe 100644 --- a/src/execute.c +++ b/src/execute.c @@ -305,8 +305,8 @@ static int setup_output(const ExecContext *context, int socket_fd, const char *i return dup2(STDIN_FILENO, STDOUT_FILENO) < 0 ? -errno : STDOUT_FILENO; /* For PID 1 stdout is always connected to /dev/null, - * hence reopen the console if necessary. */ - if (getpid() == 1) + * hence reopen the console if out parent is PID1. */ + if (getppid() == 1) return open_terminal_as(tty_path(context), O_WRONLY, STDOUT_FILENO); return STDOUT_FILENO; @@ -352,7 +352,7 @@ static int setup_error(const ExecContext *context, int socket_fd, const char *id if (e == EXEC_OUTPUT_INHERIT && o == EXEC_OUTPUT_INHERIT && i != EXEC_INPUT_NULL && - getpid () != 1) + getppid () != 1) return STDERR_FILENO; /* Duplicate form stdout if possible */ @@ -783,7 +783,13 @@ int exec_spawn(ExecCommand *command, /* child */ - reset_all_signal_handlers(); + /* We reset exactly these signals, since they are the + * only ones we set to SIG_IGN in the main daemon. All + * others we leave untouched because we set them to + * SIG_DFL or a valid handler initially, both of which + * will be demoted to SIG_DFL. */ + default_signals(SIGNALS_CRASH_HANDLER, + SIGNALS_IGNORE, -1); if (sigemptyset(&ss) < 0 || sigprocmask(SIG_SETMASK, &ss, NULL) < 0) {