Skip to main content

Thread: trap not behaving like I expect


i'm trying determine kill signals sshd sends child process when session disconnects, , thought i'd write simple bash script catches signals , writes them file, exits. having hard time trap, however. here sample program:
code:
#!~/bin/bash  echo $$   trap "echo banana" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64  while true;   sleep 9999;  done
i run this. pid 7878. in separate window, run
code:
kill -s 15 7878
i expect text "banana" show in window. not occur. however, if kill -9 7878, process dies standard "killed" output. also, if in window running script, ctrl-c, "banana" returned.

perplexed. thoughts?

it works fine, cannot trap sigkill (9). it's unconditional, gives no time gracefully exit. bam, dead.

code:
echo $$ in {1..20}; trap "echo trap: $i" $i; done while :; :; done
code:
$ ./trap.sh  | 7796         | ^ctrap: 2    | $ kill 7796 trap: 15     | $ kill -s 7 7796 trap: 7      | $ kill -s 10 7796 trap: 10     | $ kill -s 9 7796 killed       |


Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk [SOLVED] trap not behaving like I expect


Ubuntu

Comments

Popular posts from this blog

Could not place because the source rectangle is empty

Thread: Using smartcard reader with vpnc

Adobe Font Folio 7.0 or just 7?