aports/testing/shairport-sync/dont-check-pidfile-when-not-daemonised.patch
2017-04-11 13:52:14 +02:00

43 lines
1.1 KiB
Diff

From: Jakub Jirutka <jakub@jirutka.cz>
Date: Tue, 11 Apr 2017 12:24:00 +0200
Subject: [PATCH] Don't check pidfile when not --daemon
shairport reads pidfile to check if it's not already running even when
started without -d / --daemon. Thus it cannot be properly started by
init system without enabling --daemon (that's a bad practice).
This patch fixes this behaviour.
--- a/shairport.c
+++ b/shairport.c
@@ -87,7 +87,9 @@
shairport_shutdown();
// daemon_log(LOG_NOTICE, "exit...");
daemon_retval_send(255);
- daemon_pid_file_remove();
+ if (config.daemonise) {
+ daemon_pid_file_remove();
+ }
exit(0);
}
@@ -997,7 +999,7 @@
}
/* Check that the daemon is not running twice at the same time */
- if ((pid = daemon_pid_file_is_running()) >= 0) {
+ if (config.daemonise && (pid = daemon_pid_file_is_running()) >= 0) {
daemon_log(LOG_ERR, "Daemon already running on PID file %u", pid);
return 1;
}
@@ -1257,6 +1259,8 @@
finish:
daemon_log(LOG_NOTICE, "Unexpected exit...");
daemon_retval_send(255);
- daemon_pid_file_remove();
+ if (config.daemonise) {
+ daemon_pid_file_remove();
+ }
return 1;
}