When daemonizing, change umask to 0 and change working directory to /.
Patch provided by Tim Bruylants (https://github.com/tbr)
This commit is contained in:
parent
e49b71c0b7
commit
96ab05dade
@ -24,6 +24,7 @@
|
||||
#include <getopt.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@ -42,11 +43,16 @@ int daemonize()
|
||||
if (pid > 0)
|
||||
exit(0);
|
||||
|
||||
umask(0);
|
||||
|
||||
pid_t sid = setsid();
|
||||
|
||||
if (sid < 0)
|
||||
return -1;
|
||||
|
||||
if (chdir("/") < 0)
|
||||
return -1;
|
||||
|
||||
close(STDIN_FILENO);
|
||||
close(STDOUT_FILENO);
|
||||
close(STDERR_FILENO);
|
||||
|
Loading…
x
Reference in New Issue
Block a user