autoconf-patches
[Top][All Lists]
Advanced

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

Shouldn't use $? in traps for non-zero signals


From: Pavel Roskin
Subject: Shouldn't use $? in traps for non-zero signals
Date: Fri, 1 Jun 2001 14:26:05 -0400 (EDT)

Hello!

If a makefile decides to re-run configure and I interrupt it, make goes
ahead. This is very bad. It happens with bash-2.04 and CVS Autoconf.

Unfortunately, $? in trap for signals other than 0 (i.e. for real signals,
as opposed to exit) is not guaranteed to be non-zero. We don't want any of
our scripts to report success after being interrupted. This means that $?
should not be used in traps for real OS signals.

I fixed this in two macros and in some scripts. While checking the
scripts, I also found several occurences of "(exit 1); exit", which I
replaced with more portable "(exit 1); exit 1" to be coherent with the
change in AS_EXIT.

Finally, I have added a test for signal handling - if configure kills
itself if should exit with code 1. If kill doesn't work (permission
denied, $$ doesn't expand, SIGINT is not defined etc) the test is skipped.

The testsuite passes (RedHat 7.1, bash-2.04)

-- 
Regards,
Pavel Roskin

__________________________________________
--- ChangeLog
+++ ChangeLog
@@ -1 +1,11 @@
+2001-06-01  Pavel Roskin  <address@hidden>
+
+       * acgeneral.m4 (_AC_INIT_PREPARE): Don't rely on $? in the traps
+       for signals other than 0 - exit with code 1.
+       * m4sh.m4 (AS_TMPDIR): Likewise.
+       * autoconf.in: Likewise. Also don't rely on exit == exit $?.
+       * autoheader.in: Likewise.
+       * autoreconf.in: Likewise.
+       * tests/torture.at (Signal handling): New test for the above.
+
 2001-06-01  Akim Demaille  <address@hidden>
--- acgeneral.m4
+++ acgeneral.m4
@@ -1472,7 +1472,7 @@
     exit $exit_status
      ' 0
 for ac_signal in 1 2 13 15; do
-  trap 'ac_status=$?; ac_signal='$ac_signal'; AS_EXIT([$ac_status])' $ac_signal
+  trap 'ac_signal='$ac_signal'; AS_EXIT([1])' $ac_signal
 done
 ac_signal=0

--- autoconf.in
+++ autoconf.in
@@ -237,7 +237,7 @@
 $debug ||
 {
   trap 'status=$?; rm -rf $tmp && exit $status' 0
-  trap '(exit $?); exit' 1 2 13 15
+  trap '(exit 1); exit 1' 1 2 13 15
 }

 # Create a (secure) tmp directory for tmp files.
@@ -252,7 +252,7 @@
 } ||
 {
    echo "$me: cannot create a temporary directory in $TMPDIR" >&2
-   (exit 1); exit;
+   (exit 1); exit 1;
 }

 # Running m4.
@@ -282,7 +282,7 @@
   *) exec >&2
      echo "$me: invalid number of arguments."
      echo "$help"
-     (exit 1); exit ;;
+     (exit 1); exit 1 ;;
 esac

 # Unless specified, the output is stdout.
@@ -294,7 +294,7 @@
   cat >$infile
 elif test ! -r "$infile"; then
   echo "$me: $infile: No such file or directory" >&2
-  (exit 1); exit
+  (exit 1); exit 1
 fi

 # Output is produced into FD 4.  Prepare it.
@@ -316,7 +316,7 @@
   : >$tmp/forbidden.rx
   : >$tmp/allowed.rx
   $run_m4f -Dm4_warnings=$m4_warnings $infile >$tmp/configure ||
-    { (exit 1); exit; }
+    { (exit 1); exit 1; }

   if test "x$outfile" != x-; then
     chmod +x $outfile
@@ -429,7 +429,7 @@
          `$verbose "-v verbose=1"` \
          -f "$tmp/finalize.awk" <$tmp/configure >&4 ||
       { test -f "$tmp/finalize.err" && cat "$tmp/finalize.err" >&2
-        (exit 1); exit; }
+        (exit 1); exit 1; }
     test -f "$tmp/finalize.err" && cat "$tmp/finalize.err" >&2
   ;; # End of the task script.

@@ -691,16 +691,16 @@
       trace_opt="$trace_opt -t $base_name -t m4_$base_name"
       echo "$base_name$trace_format" |
         $AWK -f $tmp/translate.awk >>$tmp/trace.m4 ||
-          { (exit 1); exit; }
+          { (exit 1); exit 1; }
       echo "m4_$base_name$trace_format" |
         $AWK -f $tmp/translate.awk >>$tmp/trace.m4 ||
-          { (exit 1); exit; }
+          { (exit 1); exit 1; }
     else
       # MACRO_NAME is not a builtin.
       trace_opt="$trace_opt -t $macro_name"
       echo "$trace" |
         $AWK -f $tmp/translate.awk >>$tmp/trace.m4 ||
-          { (exit 1); exit; }
+          { (exit 1); exit 1; }
     fi
     echo >>$tmp/trace.m4
   done
@@ -740,7 +740,7 @@
        ' >&4 ||
       {
         echo "$me: tracing failed" >&2
-       (exit 1); exit
+       (exit 1); exit 1
       }
   ;;

@@ -750,7 +750,7 @@
   ## ------------ ##

   *) echo "$me: internal error: unknown task: $task" >&2
-    (exit 1); exit
+    (exit 1); exit 1
 esac

-(exit $status); exit
+(exit $status); exit $status
--- autoheader.in
+++ autoheader.in
@@ -181,7 +181,7 @@
 $debug ||
 {
   trap 'status=$?; rm -rf $tmp && exit $status' 0
-  trap '(exit $?); exit' 1 2 13 15
+  trap '(exit 1); exit 1' 1 2 13 15
 }

 # Create a (secure) tmp directory for tmp files.
@@ -196,7 +196,7 @@
 } ||
 {
    echo "$me: cannot create a temporary directory in $TMPDIR" >&2
-   (exit 1); exit
+   (exit 1); exit 1
 }

 # Preach.
@@ -219,7 +219,7 @@
     More sophisticated templates can also be produced, see the
     documentation.
 EOF
-  $warning_error && { (exit 1); exit; }
+  $warning_error && { (exit 1); exit 1; }
 fi

 acconfigs=
@@ -237,13 +237,13 @@
       *in ) infile=configure.in;;
       * )
         echo "$me: no input file" >&2
-        exit 1;;
+        (exit 1); exit 1;;
     esac;;
   1) infile=$1 ;;
   *) exec >&2
      echo "$me: invalid number of arguments."
      echo "$help"
-     (exit 1); exit ;;
+     (exit 1); exit 1;;
 esac

 # Set up autoconf.
@@ -261,14 +261,14 @@
   --trace AH_OUTPUT:'ac_verbatim_$1="\
 $2"' \
   --trace AC_DEFINE_TRACE_LITERAL:'syms="$$syms $1"' \
-  $infile >$tmp/traces.sh || { (exit 1); exit; }
+  $infile >$tmp/traces.sh || { (exit 1); exit 1; }

 $verbose $me: sourcing $tmp/traces.sh >&2
 if (set -e && . $tmp/traces.sh) >/dev/null 2>&1; then
   . $tmp/traces.sh
 else
   echo "$me: error: shell error while sourcing $tmp/traces.sh" >&2
-  (exit 1); exit
+  (exit 1); exit 1
 fi


@@ -290,7 +290,7 @@
 # Support "outfile[:infile]", defaulting infile="outfile.in".
 case "$config_h" in
 "") echo "$me: error: AC_CONFIG_HEADERS not found in $infile" >&2
-    (exit 1); exit ;;
+    (exit 1); exit 1 ;;
 *:*) config_h_in=`echo "$config_h" | sed 's/.*://'`
      config_h=`echo "$config_h" | sed 's/:.*//'` ;;
 *) config_h_in="$config_h.in" ;;
@@ -357,4 +357,4 @@
   fi
 fi

-(exit $status); exit
+(exit $status); exit $status
--- autoreconf.in
+++ autoreconf.in
@@ -251,7 +251,7 @@
 $debug ||
 {
   trap 'status=$?; rm -rf $tmp && exit $status' 0
-  trap '(exit $?); exit' 1 2 13 15
+  trap '(exit 1); exit 1' 1 2 13 15
 }

 # Create a (secure) tmp directory for tmp files.
@@ -266,7 +266,7 @@
 } ||
 {
    echo "$me: cannot create a temporary directory in $TMPDIR" >&2
-   (exit 1); exit
+   (exit 1); exit 1
 }

 # When debugging, it is convenient that all the related temporary
--- m4sh.m4
+++ m4sh.m4
@@ -479,7 +479,7 @@
 $debug ||
 {
   trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
-  trap 'AS_EXIT([$?])' 1 2 13 15
+  trap 'AS_EXIT([1])' 1 2 13 15
 }

 # Create a (secure) tmp directory for tmp files.
--- tests/torture.at
+++ tests/torture.at
@@ -346,3 +346,21 @@
 AT_CHECK([cd at-dir && $at_here/configure], [], [ignore])

 AT_CLEANUP(at-dir foo.in foo)
+
+
+## ----------------- ##
+## Signal handling.  ##
+## ----------------- ##
+
+AT_SETUP([Signal handling])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+kill -INT $$
+exit 77
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE([], 1, ignore, ignore)
+
+AT_CLEANUP
__________________________________________




reply via email to

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