Merge pull request #709 from tawm/master

Fixed PID forgetfulness.
This commit is contained in:
irungentoo 2014-01-30 15:02:19 -08:00
commit 51717825c1

View File

@ -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");