Handle more gracefully signals sent by the terminal driver
When ctrl-c is pressed on the terminal, a signal (SIGINT) is sent to all members of the foreground process group. Since both wal_writer and logger processes' default action on SIGINT is to terminate, they could terminate before parent. This led to rather nasty results: in the circumstances, when the parent somehow ignored SIGINT (e.g. under GDB), or handled it after its children (a race condition), children would disappear before parent, then parent would detect that wal_writer is gone, try to panic/write to the log, which is also gone, and on top of SIGINT get a SIGPIPE. Move spawned children to their own process groups to make sure they don't belong to the main process' process group, and don't receive signals from the controlling tty. It's okay in the interactive mode, since these children are going to die anyway when the parent dies, after getting a SIGPIPE.
Loading
Please register or sign in to comment