On 07/20/10 14:47, Eric Blake wrote a bunch of good questions,
ending with:

> And how does signal handling fit in with interrupting a child test?

OK, you're right, a plain pipe is not going to work.  How about
this much-smaller fix instead?  It builds on your idea to make
sure that the 'read at_token' commands succeed.

--- general.m4  2010-07-20 14:28:32.835139154 -0700
+++ /tmp/general.m4     2010-07-20 14:48:26.295135987 -0700
@@ -1386,7 +1386,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_FIFO_FD
 dnl Do not reraise the default PIPE handler.
 dnl It wreaks havoc with ksh, see above.
 dnl        trap - 13
@@ -1401,7 +1401,7 @@ dnl           kill -13 $$
        at_failed=:
       fi
       at_fn_group_postprocess
-      echo token >&AT_JOB_FIFO_FD
+      echo >&AT_JOB_FIFO_FD
     ) &
     $at_job_control_off
     if $at_first; then
@@ -1410,7 +1410,9 @@ dnl           kill -13 $$
     fi
     shift # Consume one token.
     if test $...@%:@] -gt 0; then :; else
-      read at_token <&AT_JOB_FIFO_FD || break
+      # The 'until' loop avoids a race condition if we happen to open
+      # the fifo between the time a child outputs a token and it exits.
+      until read at_token; do :; done <&AT_JOB_FIFO_FD
       set x $[*]
     fi
     test -f "$at_stop_file" && break
@@ -1422,7 +1424,8 @@ dnl           kill -13 $$
     shift
     for at_job
     do
-      read at_token
+      # Another 'until' loop to avoid the same race condition.
+      until read at_token; do :; done
     done <&AT_JOB_FIFO_FD
   fi
   exec AT_JOB_FIFO_FD<&-

Reply via email to