|
From: | Anoop Sharma |
Subject: | Re: [Help-bash] Bash is setting disposition of a signal, ignored upon entry to shell, to default |
Date: | Sat, 12 Jan 2013 23:05:48 +0530 |
On 1/10/13 11:42 AM, Chet Ramey wrote:
> On 1/9/13 4:09 PM, Anoop Sharma wrote:
>> 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?
OK, pretty much everything I wrote before was wrong. I should learn not to
answer these things so quickly.
I tested the script a little more, adding a program that just prints
signal dispositions, and discovered that:
1. The subshell/script does inherit the SIG_IGN disposition for SIGXFSZ.
2. The subshell/script does invoke programs with the SIG_IGN disposition
for SIGXFSZ.
3. The script, when run, displays "sleep survived the signal".
I tested bash-4.2.42 on RHEL 5 and Mac OS X.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU address@hidden http://cnswww.cns.cwru.edu/~chet/
[Prev in Thread] | Current Thread | [Next in Thread] |