| 30 | |
| 31 | |
| 32 | void ServerUtils::Daemonize() { |
| 33 | int fd; |
| 34 | |
| 35 | if (fork() != 0) exit(0); /* parent exits */ |
| 36 | setsid(); /* create a new session */ |
| 37 | |
| 38 | /* Every output goes to /dev/null. If Redis is daemonized but |
| 39 | * the 'logfile' is set to 'stdout' in the configuration file |
| 40 | * it will not log at all. */ |
| 41 | if ((fd = open("/dev/null", O_RDWR, 0)) != -1) { |
| 42 | dup2(fd, STDIN_FILENO); |
| 43 | dup2(fd, STDOUT_FILENO); |
| 44 | dup2(fd, STDERR_FILENO); |
| 45 | if (fd > STDERR_FILENO) close(fd); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | |
| 50 | } |
nothing calls this directly
no outgoing calls
no test coverage detected