autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Autotest and signal handling


From: Ralf Wildenhues
Subject: Re: Autotest and signal handling
Date: Sun, 23 Nov 2008 15:01:11 +0100
User-agent: Mutt/1.5.18 (2008-05-17)

* Ralf Wildenhues wrote on Sun, Nov 16, 2008 at 10:49:18PM CET:
> * Eric Blake wrote on Sun, Nov 16, 2008 at 10:24:10PM CET:
> > 
> > What do we do about shells, like ash, that choke on "trap ... TSTP"?
> > 
> > $ ash -c 'trap "" TSTP'
> > trap: bad signal TSTP
> 
> Which version is that?  My dash 0.5.4 on GNU/Linux does not do this.

Ping!

Anyway, my current diff on top of the patch is this.

- actually try out turning job control on and off: bash with job control
  --disable'd will exit when 'set -m' is used.
  This should allow to remove some of the 2>/dev/null redirections.
- split 'set +x +e', for assumed portability issue.
- use symbolic signal names in output if possible.
- disable parallel jobs if no job control.  This is actually only due to
  your comment; my testing indicates no advantage in doing this: the
  testsuite passes the signal tests even without job control.  Of
  course, without job control you won't get reliable C^c processing; but
  that is the case with or without --jobs=N.  So I'm not all that sure
  this is desirable.
- disable parallel jobs if trap does not understand the symbolic names
  PIPE, TSTP, STOP.  This doesn't actually test whether kill understands
  them, but I'd really hate to try out 'kill -STOP' anywhere, that's just
  such a bad idea if there is a remote chance that it could go wrong.
- typo fixes

Barring further comments, I will probably commit the patch with this
squashed in, in a couple of days.  I'll try to test some more systems
until then.

Cheers,
Ralf

diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4
index 558729d..cba5729 100644
--- a/lib/autotest/general.m4
+++ b/lib/autotest/general.m4
@@ -1200,18 +1200,18 @@ dnl shell to start each parallel task as its own shell 
job, thus as a new
 dnl process group leader.  We then send the signal to all new process groups.
 
 dnl Do we have job control?
-case `(set -o) 2>/dev/null` in #(
-*monitor*)
-   at_job_control_on='set -m' at_job_control_off='set +m' at_job_group=- ;; #(
-*) at_job_control_on=: at_job_control_off=: at_job_group= ;;
-esac
+if (set -m && set +m) >/dev/null 2>&1; then
+  at_job_control_on='set -m' at_job_control_off='set +m' at_job_group=-
+else
+  at_job_control_on=: at_job_control_off=: at_job_group=
+fi
 
 for at_signal in 1 2 15; do
 dnl This signal handler is not suitable for PIPE: it causes writes.
 dnl The code that was interrupted may have the errexit, monitor, or xtrace
 dnl flags enabled, so sanitize.
-  trap 'set +e +x
-       $at_job_control_off 2>/dev/null
+  trap 'set +x; set +e
+       $at_job_control_off
        at_signal='"$at_signal"'
 dnl Safety belt: even with runaway processes, prevent starting new jobs.
        echo stop > "$at_stop_file"
@@ -1231,7 +1231,10 @@ dnl Avoid scribbling onto the end of a possibly 
incomplete line.
        if test "$at_jobs" -eq 1 || test -z "$at_verbose"; then
          echo >&2
        fi
-       AS_WARN([caught signal $at_signal, bailing out])
+       at_signame=`kill -l $at_signal 2>&1 || echo $at_signal`
+       set x $at_signame
+       test $# -gt 2 && at_signame=$at_signal
+       AS_WARN([caught signal $at_signame, bailing out])
 dnl Do not reinstall the default handler here and reraise the signal to
 dnl let the default handler do its job, see the note about ksh above.
 dnl    trap - $at_signal
@@ -1246,7 +1249,8 @@ at_first=:
 
 if test $at_jobs -ne 1 &&
      rm -f "$at_job_fifo" &&
-     ( mkfifo "$at_job_fifo" ) 2>/dev/null &&
+     test -n "$at_job_group" &&
+     ( mkfifo "$at_job_fifo" && trap 'exit 1' PIPE STOP TSTP ) 2>/dev/null &&
      exec AT_JOB_FIFO_FD<> "$at_job_fifo"
 then
   # FIFO job dispatcher.
@@ -1289,16 +1293,16 @@ dnl cause changed test semantics; e.g., a sleep will be 
interrupted.
 dnl Enable job control only for spawning the test group:
 dnl Let the jobs to run in separate process groups, but
 dnl avoid all the status output by the shell.
-    $at_job_control_on 2>/dev/null
+    $at_job_control_on
     (
       # Start one test group.
-      $at_job_control_off 2>/dev/null
+      $at_job_control_off
 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,
 dnl except as debug measures.  However, shells such as dash may
 dnl optimize away the _AT_CHECK subshell, so normalize here.
-      trap 'set +x +e
+      trap 'set +x; set +e
 dnl Ignore PIPE signals that stem from writing back the token.
            trap "" PIPE
            echo stop > "$at_stop_file"
@@ -1319,7 +1323,7 @@ dnl           kill -13 $$
       at_fn_group_postprocess
       echo token >&AT_JOB_FIFO_FD
     ) &
-    $at_job_control_off 2>/dev/null
+    $at_job_control_off
     shift # Consume one token.
     if test address@hidden:@] -gt 0; then :; else
       read at_token <&AT_JOB_FIFO_FD || break
diff --git a/tests/autotest.at b/tests/autotest.at
index cf8d9cd..232aac8 100644
--- a/tests/autotest.at
+++ b/tests/autotest.at
@@ -998,7 +998,7 @@ for signal in 2 15; do
           [ignore], [stderr])
   AT_CHECK([grep 'bailing out' stderr], [], [ignore])
   AT_CHECK([grep 'bailing out' micro-suite.log], [], [ignore])
-  # We'd like to check this here, too, but some shells do now allow to
+  # We'd like to check this here, too, but some shells do not allow to
   # turn off job control.
   # AT_CHECK([[grep '[iI]nterrupt[      ]' stderr]], [1])
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]