help-bash
[Top][All Lists]
Advanced

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

[Help-bash] Bash is setting disposition of a signal, ignored upon entry


From: Anoop Sharma
Subject: [Help-bash] Bash is setting disposition of a signal, ignored upon entry to shell, to default
Date: Thu, 10 Jan 2013 02:39:47 +0530

Using: GNU bash, version 4.2.24(1)-release (i686-pc-linux-gnu)

I ignore a signal using trap command on an interactive shell. I expect that signal to remain ignored in the script started from the same shell. However, I find disposition of that signal reset to default, even though trap command in the script shows that signal is ignored. 

I am not sure if this is the right behavior. Please help.


Step 1 - Ignore the signal by typing the following command on an interactive shell
----------
$ trap '' SIGXFSZ

Step 2 - Given below is a script that starts a sleep in the background and then sends the signal to that sleep to test if the signal terminates the sleep or not.
---------
$ cat test_1.sh 
trap
sleep 30&
sleep 1
pid=$! 
kill -s SIGXFSZ $pid

sleep 1
kill -0 $pid && echo "sleep survived the signal" && exit
echo "sleep was terminated by the signal"

Step 3 - Even though the disposition of the signal was set to ignore in the Step 1 (and first line of the output of script confirms that), yet, the sleep is terminated by the signal. Is it right?
----------
$ ./test_1.sh 
trap -- '' SIGXFSZ
./test_1.sh: line 8:  8674 File size limit exceeded(core dumped) sleep 30
./test_1.sh: line 9: kill: (8674) - No such process
sleep was terminated by the signal



reply via email to

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