Signals in singleton processes

The first singleton process creates a listening socket in /tmp, that gets registered with the portmapper. Other singleton processes connect to an existing, registered socket.

Filesystem sockets must be explicitly removed. To avoid polluting /tmp, x::singletonapp::create() blocks the following signals: SIGINT, SIGHUP, SIGTERM, and SIGQUIT. A signal handler gets installed to catch these signals.

When any of those signals are received, the singleton process stops accepting any more connections from other application processes, and stops creating new threads, however the destructor in the singleton process cannot terminate until all existing threads terminate, first. It is expected that a receipt of this signal promptly stops all existing threads, at which point the entire singleton process terminates. This may be done in two ways: