Hi, I was playing with set -m and trapping CHLD in a script, and found the following error:
$ cat setm-bad.bash set -m i=0 trap ':; ((++i<5)) && { f & }' CHLD f(){ echo x; } f & wait $ cat setm.bash set -m i=0 trap '((++i<5)) && { f & }' CHLD f(){ echo x; } f & wait $ cat reproduce.bash for bash in /bin/bash ~/local/bin/bash ~/bb/prefix/bin/bash; do echo "$bash" "$bash" --version |& head -n1 echo setm.bash "$bash" setm.bash echo setm-bad.bash "$bash" setm-bad.bash echo ===== done $ bash reproduce.bash /bin/bash GNU bash, version 4.2.37(1)-release (x86_64-pc-linux-gnu) setm.bash x x x x x setm-bad.bash x x x x x ===== /home/dualbus/local/bin/bash GNU bash, version 4.3.0(1)-rc2 (x86_64-unknown-linux-gnu) setm.bash x x x x x setm-bad.bash x x x ===== /home/dualbus/bb/prefix/bin/bash GNU bash, version 4.3.0(1)-maint (x86_64-unknown-linux-gnu) setm.bash x x x x x setm-bad.bash x x x x x ===== The bb/prefix version is the devel branch after applying the attached patch. As you can notice, bash 4.3 exits earlier. It should do 5 iterations, but instead, it only completes 3. I found that is has something to do with using queue_sigchld_trap instead of run_sigchld_trap, which I assume fixes another issue, but the fix introduced this error. -- Eduardo A. Bustamante López
diff --git a/jobs.c b/jobs.c index 4982019..35f3f9d 100644 --- a/jobs.c +++ b/jobs.c @@ -3346,6 +3346,9 @@ itrace("waitchld: waitpid returns %d block = %d", pid, block); if (sigchld == 0) longjmp (wait_intr_buf, 1); } + else + run_sigchld_trap (children_exited); /* XXX */ +#if 0 /* If not in posix mode and not executing the wait builtin, queue the signal for later handling. Run the trap immediately if we are executing the wait builtin, but don't break out of `wait'. */ @@ -3357,6 +3360,7 @@ itrace("waitchld: waitpid returns %d block = %d", pid, block); run_sigchld_trap (children_exited); /* XXX */ else queue_sigchld_trap (children_exited); +#endif } /* We have successfully recorded the useful information about this process