mirror of
https://github.com/dschmenk/apple2pi.git
synced 2024-11-28 09:49:27 +00:00
Switch to GNU daemon() call
This commit is contained in:
parent
3dcd243972
commit
c4ba6192dd
28
src/a2pid.c
28
src/a2pid.c
@ -540,32 +540,8 @@ void main(int argc, char **argv)
|
||||
*/
|
||||
if (strcmp(argv[1], "--daemon") == 0)
|
||||
{
|
||||
pid_t pid, sid; /* our process ID and Session ID */
|
||||
|
||||
pid = fork(); /* fork off the parent process */
|
||||
if (pid < 0)
|
||||
die("a2pid: fork() failure");
|
||||
/*
|
||||
* If we got a good PID, then
|
||||
* we can exit the parent process
|
||||
*/
|
||||
if (pid > 0)
|
||||
exit(EXIT_SUCCESS);
|
||||
umask(0); /* change the file mode mask */
|
||||
/*
|
||||
* Open any logs here
|
||||
*/
|
||||
sid = setsid(); /* create a new SID for the child process */
|
||||
if (sid < 0)
|
||||
die("a2pid: setsid() failure");
|
||||
if ((chdir("/")) < 0) /* change the current working directory */
|
||||
die("a2pid: chdir() failure");
|
||||
/*
|
||||
* Close out the standard file descriptors
|
||||
*/
|
||||
close(STDIN_FILENO);
|
||||
close(STDOUT_FILENO);
|
||||
close(STDERR_FILENO);
|
||||
if (daemon(0, 0) != 0)
|
||||
die("a2pid: daemon() failure");
|
||||
isdaemon = TRUE;
|
||||
/*
|
||||
* Another argument must be tty device
|
||||
|
Loading…
Reference in New Issue
Block a user