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