Advertisement
jimklimov

Jeknins intercepts signals

Jan 3rd, 2018
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.69 KB | None | 0 0
  1. # Jenkins "Execute shell" build step to see signals blocked by Jenkins and
  2. # so not-caught by child processes, such as apparently SIGQUIT (3).
  3. # Note this may behave slightly differently in different system shells -
  4. # e.g. bash did not block SIGINT (2) for me, but dash and ksh did.
  5. # You may want a shebang on top for deterministic behavior of a specific
  6. # shell, rather than current build agent's /bin/sh implementation.
  7. RES=0
  8.  
  9. for SIG in 1 2 3 15 ; do
  10.     echo "SIG = $SIG"
  11.     ( trap "echo 'Got hit by $SIG' >&2 ; exit 0 ;" $SIG
  12.       sleep 5
  13.       echo "ERROR: Did not get SIG = $SIG" >&2
  14.       exit 1 ) &
  15.     sleep 1
  16.     kill -$SIG $! || RES=$?
  17.     wait $! || RES=$?
  18. done
  19.  
  20. exit $RES
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement