On 07/20/10 14:55, Eric Blake wrote: > the '|| break' that you are deleting is there in case > something kills off the child and it never gets around to writing a > token, at which point we've now put the parent into an inf-loop
OK, though if the child is killed off arbitrarily then we're helpless (the first child could get killed before it opens the fifo, which means the parent will wait forever trying to open the fifo); but I see what you mean: that patch made infinite loops too likely in the presence of arbitrary child failure. How about this idea instead: have the parent open the fifo for output, except do this _after_ the first job has started (so we know we can open the fifo without hanging, under the same assumptions as before). That way, the race condition is closed. Something like this: --- general.m4 2010-07-20 15:23:26.823143793 -0700 +++ /tmp/general.m4 2010-07-20 15:37:36.719138878 -0700 @@ -960,6 +960,7 @@ export PATH # Setting up the FDs. m4_define([AS_MESSAGE_LOG_FD], [5]) m4_define([AT_JOB_FIFO_FD], [6]) +m4_define([AT_JOB_OUTFIFO_FD], [7]) [#] AS_MESSAGE_LOG_FD is the log file. Not to be overwritten if `-d'. if $at_debug_p; then at_suite_log=/dev/null @@ -1376,7 +1377,9 @@ dnl avoid all the status output by the s ( # Start one test group. $at_job_control_off - exec AT_JOB_FIFO_FD>"$at_job_fifo" + if $at_first; then + exec AT_JOB_OUTFIFO_FD>"$at_job_fifo" + fi dnl When a child receives PIPE, be sure to write back the token, dnl so the master does not hang waiting for it. dnl errexit and xtrace should not be set in this shell instance, @@ -1386,7 +1389,7 @@ dnl optimize away the _AT_CHECK subshell dnl Ignore PIPE signals that stem from writing back the token. trap "" PIPE echo stop > "$at_stop_file" - echo token >&AT_JOB_FIFO_FD + echo >&AT_JOB_OUTFIFO_FD dnl Do not reraise the default PIPE handler. dnl It wreaks havoc with ksh, see above. dnl trap - 13 @@ -1395,18 +1398,19 @@ dnl kill -13 $$ at_fn_group_prepare if cd "$at_group_dir" && at_fn_test $at_group && - . "$at_test_source" # AT_JOB_FIFO_FD>&- + . "$at_test_source" # AT_JOB_OUTFIFO_FD>&- then :; else AS_WARN([unable to parse test group: $at_group]) at_failed=: fi at_fn_group_postprocess - echo token >&AT_JOB_FIFO_FD + echo >&AT_JOB_OUTFIFO_FD ) & $at_job_control_off if $at_first; then at_first=false exec AT_JOB_FIFO_FD<"$at_job_fifo" + exec AT_JOB_OUTFIFO_FD>"$at_job_fifo" fi shift # Consume one token. if test $...@%:@] -gt 0; then :; else @@ -1415,6 +1419,7 @@ dnl kill -13 $$ fi test -f "$at_stop_file" && break done + exec AT_JOB_OUTFIFO_FD<&- # Read back the remaining ($at_jobs - 1) tokens. set X $at_joblist shift