so much space…

JSON-23
Roker 6 years ago
parent 3b3b328086
commit e606bcb34e

@ -22,36 +22,36 @@ void daemonize()
{
/* already a daemon */
if ( getppid() == 1 ) return;
/* Fork off the parent process */
pid_t pid = fork();
if (pid < 0)
if (pid < 0)
{
throw std::runtime_error("Cannot fork!");
}
if (pid > 0)
{
}
if (pid > 0)
{
exit(EXIT_SUCCESS); /*Killing the Parent Process*/
}
}
/* At this point we are executing as the child process */
/* Create a new SID for the child process */
pid_t sid = setsid();
if (sid < 0)
if (sid < 0)
{
throw std::runtime_error("Cannot call setsid()");
}
int fd = open("/dev/null",O_RDWR, 0);
const int fd = open("/dev/null",O_RDWR, 0);
if (fd != -1)
{
dup2 (fd, STDIN_FILENO);
dup2 (fd, STDOUT_FILENO);
dup2 (fd, STDERR_FILENO);
if (fd > 2)
{
close (fd);

Loading…
Cancel
Save