diff options
author | 2016-09-22 14:35:04 -0500 | |
---|---|---|
committer | 2016-09-22 15:40:23 -0500 | |
commit | befc6dbd6469d428c9e0830dbe51bdf7ac39d9ae (patch) | |
tree | b8df1b683c3b7523a8d05d485c62b4468c4883a4 | |
parent | f4b1c752186f4d08f1fadb0ea10ebcde9b0ea251 (diff) | |
download | pseudo-befc6dbd6469d428c9e0830dbe51bdf7ac39d9ae.tar.gz pseudo-befc6dbd6469d428c9e0830dbe51bdf7ac39d9ae.tar.bz2 pseudo-befc6dbd6469d428c9e0830dbe51bdf7ac39d9ae.zip |
Don't send SIGUSR1 to init.
If the parent exits due to child process being slow, getppid() will return
1, and we'll send SIGUSR1 to init, which can break things like dumbinit
which aren't adequately protected against non-root processes sending them
signals.
Signed-off-by: Seebs <seebs@seebs.net>
-rw-r--r-- | ChangeLog.txt | 3 | ||||
-rw-r--r-- | pseudo_server.c | 11 |
2 files changed, 11 insertions, 3 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt index 8eb7917..f746c18 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,6 @@ +2016-09-22: + * (seebs) don't send SIGUSR1 to init. + 2016-07-29: * (seebs) Don't clear bindings for a statement with no bindings. diff --git a/pseudo_server.c b/pseudo_server.c index 65102dd..8731d20 100644 --- a/pseudo_server.c +++ b/pseudo_server.c @@ -358,9 +358,14 @@ pseudo_server_start(int daemonize) { signal(SIGTERM, quit_now); /* tell parent process to stop waiting */ if (daemonize) { - pseudo_diag("Setup complete, sending SIGUSR1 to pid %d.\n", - getppid()); - kill(getppid(), SIGUSR1); + pid_t ppid = getppid(); + if (ppid == 1) { + pseudo_diag("Setup complete, but parent is init, not sending SIGUSR1.\n"); + } else { + pseudo_diag("Setup complete, sending SIGUSR1 to pid %d.\n", + ppid); + kill(ppid, SIGUSR1); + } } pseudo_server_loop(); return 0; |