0001-daemon.patch 802 B

12345678910111213141516171819202122232425262728293031323334
  1. written by Mike Frysinger
  2. https://sourceforge.net/tracker/?func=detail&aid=3132053&group_id=5616&atid=305616
  3. Rather than using the fork function (which doesnt work on nommu
  4. systems), simply use the daemon() function instead (which does
  5. work). this should work the same before and after for all systems.
  6. --- a/irattach/util.c
  7. +++ b/irattach/util.c
  8. @@ -156,21 +156,10 @@
  9. void fork_now(int ttyfd)
  10. {
  11. - int ret;
  12. int i;
  13. - if ((ret = fork()) > 0)
  14. - exit(0);
  15. -
  16. - if (ret == -1)
  17. - syslog(LOG_INFO, "forking: %m");
  18. - if (setsid() < 0)
  19. - syslog(LOG_INFO, "detaching from tty: %m");
  20. -
  21. - if ((ret = fork()) > 0) {
  22. - /* cleanup_files = 0; */
  23. - exit(0);
  24. - }
  25. + if (daemon(1, 1))
  26. + syslog(LOG_INFO, "daemon: %m");
  27. /* Close all open inherited files! Except for ttyfd! */
  28. for (i = 0; i < 64; i++)