From 04580cf122f4b85bd9f49a7d2c7f4df7299ed9d7 Mon Sep 17 00:00:00 2001 From: tawm Date: Thu, 30 Jan 2014 15:56:45 -0500 Subject: Fixed PID forgetfulness. --- other/bootstrap_serverdaemon/tox_bootstrap_daemon.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'other/bootstrap_serverdaemon/tox_bootstrap_daemon.c') diff --git a/other/bootstrap_serverdaemon/tox_bootstrap_daemon.c b/other/bootstrap_serverdaemon/tox_bootstrap_daemon.c index e82e49cd..f2c54bb1 100644 --- a/other/bootstrap_serverdaemon/tox_bootstrap_daemon.c +++ b/other/bootstrap_serverdaemon/tox_bootstrap_daemon.c @@ -398,11 +398,14 @@ int main(int argc, char *argv[]) pid_t pid = fork(); if (pid < 0) { + fclose(pidf); syslog(LOG_ERR, "Forking failed. Exiting.\n"); return 1; } if (pid > 0) { + fprintf(pidf, "%d\n", pid); + fclose(pidf); syslog(LOG_DEBUG, "Forked successfully: PID: %d.\n", pid); return 0; } @@ -410,9 +413,6 @@ int main(int argc, char *argv[]) // Change the file mode mask umask(0); - fprintf(pidf, "%d\n", pid); - fclose(pidf); - // Create a new SID for the child process if (setsid() < 0) { syslog(LOG_ERR, "SID creation failure. Exiting.\n"); -- cgit v1.2.3