From 9cacde056ce7f6bd4b3a2f181017a33c6dff3e5a Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Mon, 19 Apr 2021 12:46:58 -0700 Subject: setsid(1): call setsid(2) before setpgrp(2). The new cpio test that uses setsid fails if you're using the toybox setsid. Move the setpgrp() call before the vfork() but after the setsid(). --- toys/other/setsid.c | 9 +++++---- 1 file 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)) { -- cgit v1.2.3