daemonize.h 670 B

123456789101112131415161718192021
  1. /* Licensed under BSD-MIT - see LICENSE file for details */
  2. #ifndef CCAN_DAEMONIZE_H
  3. #define CCAN_DAEMONIZE_H
  4. #include <stdbool.h>
  5. /**
  6. * daemonize - turn this process into a daemon.
  7. *
  8. * This routine forks us off to become a daemon. It returns false on failure
  9. * (eg. fork(), chdir or open failed) and sets errno.
  10. *
  11. * Side effects for programmers to be aware of:
  12. * - PID changes (our parent exits, we become child of init)
  13. * - stdin and stdout file descriptors are closed
  14. * - stderr is reopened to /dev/null so you don't reuse it
  15. * - Current working directory changes to /
  16. * - Umask is set to 0.
  17. */
  18. bool daemonize(void);
  19. #endif /* CCAN_DAEMONIZE_H */