diff --git a/src/replication.cc b/src/replication.cc index c7173bc5d884ddbbb33f5dbaab7efb85fcf7d95b..747a7d4ddc123c28c3a0b1bc08b03faeb7501a79 100644 --- a/src/replication.cc +++ b/src/replication.cc @@ -290,9 +290,9 @@ replication_send_socket(ev_io *watcher, int events __attribute__((unused))) } -/*-----------------------------------------------------------------------------*/ -/* spawner process */ -/*-----------------------------------------------------------------------------*/ +/*--------------------------------------------------------------------------* + * spawner process * + * -------------------------------------------------------------------------*/ /** Initialize the spawner. */ @@ -336,6 +336,21 @@ spawner_init(int sock) if (sigaction(SIGCHLD, &sa, NULL) == -1) say_syserror("sigaction"); + sa.sa_handler = SIG_IGN; + /* + * Ignore SIGUSR1, SIGUSR1 is used to make snapshots, + * and if someone wrote a faulty regexp for `ps' and + * fed it to `kill' the replication shouldn't die. + */ + if (sigaction(SIGUSR1, &sa, NULL) == -1) + say_syserror("sigaction"); + /* + * Ignore SIGUSR2 as well, since one can be pretty + * inventive in ways of shooting oneself in the foot. + */ + if (sigaction(SIGUSR2, &sa, NULL) == -1) + say_syserror("sigaction"); + say_crit("initialized"); spawner_main_loop(); } @@ -397,6 +412,15 @@ spawner_main_loop() static void spawner_shutdown() { + /* + * There is no need to ever use signals with the spawner + * process. If someone did send spawner a signal by + * mistake, at least make a squeak in the error log before + * dying. + */ + if (spawner.killed) + say_info("Terminated by signal %d", (int) spawner.killed); + /* close socket */ close(spawner.sock); @@ -612,10 +636,23 @@ replication_relay_loop(int client_sock) sigaction(SIGTERM, &sa, NULL) == -1) say_syserror("sigaction"); - /* Block SIGPIPE, we already handle EPIPE. */ + /* Ignore SIGPIPE, we already handle EPIPE. */ sa.sa_handler = SIG_IGN; if (sigaction(SIGPIPE, &sa, NULL) == -1) say_syserror("sigaction"); + /* + * Ignore SIGUSR1, SIGUSR1 is used to make snapshots, + * and if someone wrote a faulty regexp for `ps' and + * fed it to `kill' the replication shouldn't die. + */ + if (sigaction(SIGUSR1, &sa, NULL) == -1) + say_syserror("sigaction"); + /* + * Ignore SIGUSR2 as well, since one can be pretty + * inventive in ways of shooting oneself in the foot. + */ + if (sigaction(SIGUSR2, &sa, NULL) == -1) + say_syserror("sigaction"); r = read(client_sock, &lsn, sizeof(lsn)); if (r != sizeof(lsn)) {