[PATCH 04/17] daemons: fix setsid(2) in console-run
Only run setsid(2) if the process is not already the group leader.
* daemons/console-run.c (open_console): Fix setsid(2).
---
daemons/console-run.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/daemons/console-run.c b/daemons/console-run.c
index fb879e5..e1bfe64 100644
--- a/daemons/console-run.c
+++ b/daemons/console-run.c
@@ -217,8 +217,9 @@ open_console (char **namep)
dup2 (0, 1);
dup2 (0, 2);
- if (setsid () == -1)
- error (0, errno, "setsid");
+ if (getsid (0) != getpid ())
+ if (setsid () == -1)
+ error (0, errno, "setsid");
/* Set the console to our pgrp. */
tcsetpgrp (0, getpid ());
--
1.7.10.4
Reply to: