Skip to content

Commit

Permalink
package: fix SIGINT and SIGHUP handling
Browse files Browse the repository at this point in the history
The package script was not well behaved with these. When you
pressed Ctrl+C, on some shells (including ksh) both the SIGINT (2)
and EXIT (0) traps are activated, showing a double 'make done'
message. The exit status also wasn't > 128 to indicate a signal.

bin/package, src/cmd/INIT/package.sh:
- Be UNIXly well-behaved. Signals should be passed on after
  handling, so when one is caught, make the trap handlers print
  their message and then unset both itself and EXIT/0 before
  resending the signal to self.
  • Loading branch information
McDutchie committed Mar 17, 2021
1 parent 4443872 commit 82c6922
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions bin/package
Original file line number Diff line number Diff line change
Expand Up @@ -3999,9 +3999,12 @@ capture() # file command ...
note $action output captured in $o
s="$command: $action start at `date` in $INSTALLROOT"
case $quiet in
0) trap "echo \"$command: $action done at \`date\`\" in $INSTALLROOT 2>&1 | \$TEE -a $o" 0 1 2 ;;
*) trap "echo \"$command: $action done at \`date\`\" in $INSTALLROOT >> $o" 0 1 2 ;;
0) cmd="echo \"$command: $action done at \`date\`\" in $INSTALLROOT 2>&1 | \$TEE -a $o" ;;
*) cmd="echo \"$command: $action done at \`date\`\" in $INSTALLROOT >> $o" ;;
esac
trap "$cmd" 0
trap "$cmd; trap 1 0; kill -1 $$" 1
trap "$cmd; trap 2 0; kill -2 $$" 2
;;
esac
case $quiet in
Expand Down
7 changes: 5 additions & 2 deletions src/cmd/INIT/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3999,9 +3999,12 @@ capture() # file command ...
note $action output captured in $o
s="$command: $action start at `date` in $INSTALLROOT"
case $quiet in
0) trap "echo \"$command: $action done at \`date\`\" in $INSTALLROOT 2>&1 | \$TEE -a $o" 0 1 2 ;;
*) trap "echo \"$command: $action done at \`date\`\" in $INSTALLROOT >> $o" 0 1 2 ;;
0) cmd="echo \"$command: $action done at \`date\`\" in $INSTALLROOT 2>&1 | \$TEE -a $o" ;;
*) cmd="echo \"$command: $action done at \`date\`\" in $INSTALLROOT >> $o" ;;
esac
trap "$cmd" 0
trap "$cmd; trap 1 0; kill -1 $$" 1
trap "$cmd; trap 2 0; kill -2 $$" 2
;;
esac
case $quiet in
Expand Down

0 comments on commit 82c6922

Please sign in to comment.