# DIY Linux Patch
Date: 2004-09-17
Author: Tim Waugh <twaugh@redhat.com>
Origin: http://lists.gnu.org/archive/html/bug-bash/2004-09/msg00081.html
Maker: Greg Schafer <gschafer@zip.com.au>
Upstream Status: See Origin. Reported to bug-bash, waiting
Description: After this change went into Glibc CVS;
  http://sources.redhat.com/ml/glibc-cvs/2004-q3/msg00589.html
  bash no longer works properly when using Glibc's waitpid-based generic code.
  More info here;
  http://www.diy-linux.org/pipermail/diy-linux-dev/2004-September/000165.html
Revision-2: 2004-10-12 Remade to incorporate a small fix found in
  `bash-jobs.patch' from Fedora bash-3.0-16.src.rpm

diff -Naur bash-3.0.orig/jobs.c bash-3.0/jobs.c
--- bash-3.0.orig/jobs.c	2004-10-12 08:50:11.643481280 +0000
+++ bash-3.0/jobs.c	2004-10-12 08:51:35.110792320 +0000
@@ -2476,6 +2476,7 @@
   PROCESS *child;
   pid_t pid;
   int call_set_current, last_stopped_job, job, children_exited, waitpid_flags;
+  static int wcontinued_not_supported = 0;
 
   call_set_current = children_exited = 0;
   last_stopped_job = NO_JOB;
@@ -2489,7 +2490,15 @@
 			: 0;
       if (sigchld || block == 0)
 	waitpid_flags |= WNOHANG;
+    retry:
+      if (wcontinued_not_supported)
+	waitpid_flags &= ~WCONTINUED;
       pid = WAITPID (-1, &status, waitpid_flags);
+      if (pid == -1 && errno == EINVAL)
+	{
+	  wcontinued_not_supported = 1;
+	  goto retry;
+	}
 
       /* The check for WNOHANG is to make sure we decrement sigchld only
 	 if it was non-zero before we called waitpid. */
