5 /* Helper functions to "daemonize" forb servers. To make debugging
6 * easier, we do not detach from terminal. The idea behind daemonizing
7 * is to exit the parent when the server is ready to receive requests,
8 * so that is is not necessary to put delays between invocation of
9 * different servers. */
11 static int daemon_pipe[2] = { 0, 0 };
13 void forb_daemon_prepare(const char *pid)
20 ret = pipe(daemon_pipe);
30 if (child > 0) { /* In parent */
31 close(daemon_pipe[1]);
32 ret = read(daemon_pipe[0], &tmp, 1);
36 fprintf(f, "%d\n", child);
40 exit(ret > 0 ? 0 : 1);
41 } else { /* In chind */
42 close(daemon_pipe[0]);
47 * Signal the parent that the daemon is ready so that the parent can
50 void forb_daemon_ready()
53 write(daemon_pipe[1], "", 1);