Move up waitpid error check so that errno isn't clobbered by tcsetpgrp.
authorMatt Kraai <kraai@debian.org>
Wed, 2 May 2001 21:48:17 +0000 (21:48 -0000)
committerMatt Kraai <kraai@debian.org>
Wed, 2 May 2001 21:48:17 +0000 (21:48 -0000)
hush.c
shell/hush.c

diff --git a/hush.c b/hush.c
index 4a16a3fa63765565ad7fbb4c4b55c91fa7d58c2b..a7316f82eabcb8c98ea5daab55b43066c26576f3 100644 (file)
--- a/hush.c
+++ b/hush.c
@@ -1148,12 +1148,12 @@ static void checkjobs()
                }
        }
 
+       if (childpid == -1 && errno != ECHILD)
+               perror_msg("waitpid");
+
        /* move the shell to the foreground */
        if (tcsetpgrp(0, getpgrp()) && errno != ENOTTY)
                perror_msg("tcsetpgrp"); 
-
-       if (childpid == -1 && errno != ECHILD)
-               perror_msg("waitpid");
 }
 
 /* run_pipe_real() starts all the jobs, but doesn't wait for anything
index 4a16a3fa63765565ad7fbb4c4b55c91fa7d58c2b..a7316f82eabcb8c98ea5daab55b43066c26576f3 100644 (file)
@@ -1148,12 +1148,12 @@ static void checkjobs()
                }
        }
 
+       if (childpid == -1 && errno != ECHILD)
+               perror_msg("waitpid");
+
        /* move the shell to the foreground */
        if (tcsetpgrp(0, getpgrp()) && errno != ENOTTY)
                perror_msg("tcsetpgrp"); 
-
-       if (childpid == -1 && errno != ECHILD)
-               perror_msg("waitpid");
 }
 
 /* run_pipe_real() starts all the jobs, but doesn't wait for anything