blob: fc952d24794db9d630cecaaee3010e19d9422481 (
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.3 2004/07/10 21:00:00 wiz Exp $
--- src/task.c.orig 1999-02-18 00:32:18.000000000 +0100
+++ src/task.c
@@ -5903,12 +5903,20 @@ task_daemonize __PF0(void)
}
/* 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);
@@ -5927,7 +5935,7 @@ task_daemonize __PF0(void)
/* Parent */
exit(0);
}
-#else /* USE_SETPGRP */
+#else /* defined(USE_SETPGRP) || defined(USE_SETSID) */
t = setpgrp(0, getpid());
if (t < 0) {
perror("task_daemonize: setpgrp");
@@ -5942,7 +5950,7 @@ task_daemonize __PF0(void)
}
(void) close(t);
}
-#endif /* USE_SETPGRP */
+#endif /* defined(USE_SETPGRP) || defined(USE_SETSID) */
}
/* Close all open files */
|