unix/SignalHandlers: shut down if parent process dies in --no-daemon mode

By default, if the parent of a process dies, the process gets SIGHUP
and is supposed to shut down.  This however doesn't work for MPD,
because MPD redefines SIGHUP with a different meaning (like most
daemons do).

To work around this, we configure the kernel to send SIGTERM instead
of SIGHUP.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/1706
This commit is contained in:
Max Kellermann
2023-03-06 12:53:19 +01:00
parent 6e700dab69
commit a0f6932ebe
4 changed files with 22 additions and 5 deletions

View File

@@ -482,7 +482,10 @@ MainConfigured(const CommandLineOptions &options,
#ifndef ANDROID
setup_log_output();
const ScopeSignalHandlersInit signal_handlers_init(instance);
const ScopeSignalHandlersInit signal_handlers_init{
instance,
options.daemon,
};
#endif
instance.io_thread.Start();