diff options
Diffstat (limited to 'toys/other')
-rw-r--r-- | toys/other/setsid.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/toys/other/setsid.c b/toys/other/setsid.c index 70672424..654ce7a1 100644 --- a/toys/other/setsid.c +++ b/toys/other/setsid.c @@ -24,14 +24,15 @@ void setsid_main(void) { int i; - // This must be before vfork() or tcsetpgrp() will hang waiting for parent. - setpgid(0, 0); - // setsid() fails if we're already session leader, ala "exec setsid" from sh. // Second call can't fail, so loop won't continue endlessly. while (setsid()<0) { - pid_t pid = XVFORK(); + pid_t pid; + + // This must be before vfork() or tcsetpgrp() will hang waiting for parent. + setpgid(0, 0); + pid = XVFORK(); if (pid) { i = 0; if (FLAG(w)) { |