blob: ea2e497a7b682f6d025d4d22660ba4689e420677 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
$NetBSD: patch-ab,v 1.2 1998/08/07 11:10:39 agc Exp $
--- src/task.c.orig Fri Jul 18 06:45:02 1997
+++ src/task.c Wed Oct 1 21:40:45 1997
@@ -5868,12 +5868,20 @@
}
/* Remove our association with a controling tty */
-#ifdef USE_SETPGRP
+#if defined(USE_SETPGRP) || defined(USE_SETSID)
+#if defined(USE_SETPGRP)
t = setpgrp();
if (t < 0) {
perror("task_daemonize: setpgrp");
exit(1);
}
+#else /* USE_SETPGRP */
+ t = setsid();
+ if (t < 0) {
+ perror("task_daemonize: setsid");
+ exit(1);
+ }
+#endif /* USE_SETPGRP */
task_signal_ignore(SIGHUP);
@@ -5892,7 +5900,7 @@
/* Parent */
exit(0);
}
-#else /* USE_SETPGRP */
+#else /* defined(USE_SETPGRP) || defined(USE_SETSID) */
t = setpgrp(0, getpid());
if (t < 0) {
perror("task_daemonize: setpgrp");
@@ -5907,7 +5915,7 @@
}
(void) close(t);
}
-#endif /* USE_SETPGRP */
+#endif /* defined(USE_SETPGRP) || defined(USE_SETSID) */
}
/* Close all open files */
|