daemon_with_notify.h 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. /* Licensed under BSD 3-clause: see LICENSE */
  2. #ifndef CCAN_DAEMON_WITH_NOTIFY_H
  3. #define CCAN_DAEMON_WITH_NOTIFY_H
  4. /**
  5. * daemonize - turns this process into a daemon
  6. *
  7. * This routine will fork() us off to become a daemon. It will return
  8. * -1 on error and 0 on success.
  9. *
  10. * It has a few optional behaviours:
  11. * @nochdir: if nochdir is set, it won't chdir to /
  12. * this means we could hold onto mounts
  13. * @noclose: if noclose is set, we won't close stdout, stdin and stderr.
  14. * @wait_sigusr1: if wait_sigusr1 is set, the parent will not exit until the
  15. * child has either exited OR it receives a SIGUSR1 signal. You can use this
  16. * to have the parent only exit when your process has done all the
  17. * danegerous initialization that could cause it to fail to start
  18. * (e.g. allocating large amounts of memory, replaying REDO logs).
  19. * This allows init scripts starting the daemon to easily report
  20. * success/failure.
  21. */
  22. int daemonize(int nochdir, int noclose, int wait_sigusr1);
  23. /**
  24. * daemon_is_ready - signals parent that it can exit, we started okay
  25. *
  26. * After a daemonize() call, this function will send a SIGUSR1 to the parent
  27. * telling it to exit as we have started up okay.
  28. */
  29. int daemon_is_ready(void);
  30. #endif /* CCAN_DAEMON_WITH_NOTIFY_H */