# --- T2-COPYRIGHT-NOTE-BEGIN --- # This copyright note is auto-generated by ./scripts/Create-CopyPatch. # # T2 SDE: package/.../bash/3.0-jobs.patch # Copyright (C) 2004 - 2005 The T2 SDE Project # # More information can be found in the files COPYING and README. # # This patch file is dual-licensed. It is available under the license the # patched project is licensed under, as long as it is an OpenSource license # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms # of the GNU General Public License as published by the Free Software # Foundation; either version 2 of the License, or (at your option) any later # version. # --- T2-COPYRIGHT-NOTE-END --- Some job-control hacking imported from gentoo. Fixes infinte waiting for executed jobs. - Rene Rebe --- bash-3.0/tests/jobs4.sub.jobs 2004-05-06 14:02:41.000000000 +0100 +++ bash-3.0/tests/jobs4.sub 2004-09-08 16:07:25.305385245 +0100 @@ -18,5 +18,5 @@ wait -cat & +sleep 100 & kill -1 %% && echo i killed it || echo could not kill it --- bash-3.0/jobs.c.jobs 2004-09-08 16:07:25.081427747 +0100 +++ bash-3.0/jobs.c 2004-09-08 16:18:06.698604033 +0100 @@ -2475,6 +2475,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; @@ -2488,7 +2489,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. */