From 8b5e3d520825f3376ec0fd00ba3aadc60c625d5f Mon Sep 17 00:00:00 2001 From: Maxim Biro Date: Sun, 18 May 2014 19:26:36 -0400 Subject: [PATCH] Allow multiple instances of the daemon --- other/bootstrap_daemon/tox_bootstrap_daemon.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/other/bootstrap_daemon/tox_bootstrap_daemon.c b/other/bootstrap_daemon/tox_bootstrap_daemon.c index 2c8f7014..0d18d411 100644 --- a/other/bootstrap_daemon/tox_bootstrap_daemon.c +++ b/other/bootstrap_daemon/tox_bootstrap_daemon.c @@ -485,8 +485,7 @@ int main(int argc, char *argv[]) // Check if the PID file exists if (fopen(pid_file_path, "r")) { - syslog(LOG_ERR, "Another instance of the daemon is already running, PID file %s exists. Exiting.\n", pid_file_path); - return 1; + syslog(LOG_ERR, "Another instance of the daemon is already running, PID file %s exists.\n", pid_file_path); } IP ip; @@ -555,10 +554,10 @@ int main(int argc, char *argv[]) print_public_key(dht->self_public_key); // Write the PID file - FILE *pidf = fopen(pid_file_path, "w"); + FILE *pidf = fopen(pid_file_path, "a+"); if (pidf == NULL) { - syslog(LOG_ERR, "Can't open the PID file for writing: %s. Exiting.\n", pid_file_path); + syslog(LOG_ERR, "Couldn't open the PID file for writing: %s. Exiting.\n", pid_file_path); return 1; } @@ -575,7 +574,7 @@ int main(int argc, char *argv[]) } if (pid > 0) { - fprintf(pidf, "%d\n", pid); + fprintf(pidf, "%d ", pid); fclose(pidf); syslog(LOG_DEBUG, "Forked successfully: PID: %d.\n", pid); return 0;