Fixed PID forgetfulness.

This commit is contained in:
tawm 2014-01-30 15:56:45 -05:00
parent a13e30e8bb
commit 04580cf122

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