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(-)
From ef4fa9e1ee6cc24eec7a74eadc4a08eaddddf347 Mon Sep 17 00:00:00 2001 From: Elliott Hughes <e...@google.com> Date: Mon, 19 Apr 2021 12:46:58 -0700 Subject: [PATCH] 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)) { -- 2.31.1.368.gbe11c130af-goog
_______________________________________________ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net