aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2021-04-19 12:46:58 -0700
committerRob Landley <rob@landley.net>2021-04-20 03:29:59 -0500
commit9cacde056ce7f6bd4b3a2f181017a33c6dff3e5a (patch)
treeabfe09637fc32dcf4c7e7e01792d7e20da7c9e77
parent95a15d238120167959bd7aee3e71ac5be3a72804 (diff)
downloadtoybox-9cacde056ce7f6bd4b3a2f181017a33c6dff3e5a.tar.gz
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().
-rw-r--r--toys/other/setsid.c9
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)) {