MCPcopy Create free account
hub / github.com/Tencent/phxrpc / Daemonize

Method Daemonize

phxrpc/rpc/server_base.cpp:32–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30
31
32void 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}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected