floobit
November 16th, 2012, 10:31 PM
I'm trying to determine what kill signals sshd sends a child process when a session disconnects, and thought I'd write a simple bash script that catches all the signals and writes them to a file, then exits. I am having a hard time with trap, however. Here is a sample program:
#!~/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;
do
sleep 9999;
done
I run this. Say the pid is 7878. In a separate window, I run
kill -s 15 7878
I would expect the text "banana" to show up in my window. This does not occur. However, if I do a kill -9 7878, the process dies successfully with only the standard "Killed" as output. Also, if in the window running my script, I do ctrl-C, "banana" is returned.
I am perplexed. Thoughts?
#!~/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;
do
sleep 9999;
done
I run this. Say the pid is 7878. In a separate window, I run
kill -s 15 7878
I would expect the text "banana" to show up in my window. This does not occur. However, if I do a kill -9 7878, the process dies successfully with only the standard "Killed" as output. Also, if in the window running my script, I do ctrl-C, "banana" is returned.
I am perplexed. Thoughts?