@@ -1173,8 +1173,7 @@
STATIC int
waitproc(int block, int *status)
{
- sigset_t oldmask;
- int flags = block == DOWAIT_BLOCK ? 0 : WNOHANG;
+ int flags = block != DOWAIT_NONBLOCK ? 0 : WNOHANG;
int err;
#if JOBS
@@ -1186,19 +1185,19 @@
gotsigchld = 0;
do
err = wait3(status, flags, NULL);
- while (err < 0 && errno == EINTR);
+ while (err < 0 && errno == EINTR && !pending_sig);
if (err || (err = -!block))
break;
- sigblockall(&oldmask);
-
- while (!gotsigchld && !pending_sig)
- sigsuspend(&oldmask);
-
- sigclearmask();
} while (gotsigchld);
+ if(block == DOWAIT_WAITCMD &&
+ err < 0 && errno == EINTR && pending_sig)
+ /* If block is DOWAIT_WAITCMD, we return 0 when a signal
+ * other than SIGCHLD interrupted the wait. */
+ return 0;
+
return err;
}