help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Bash is setting disposition of a signal, ignored upon en


From: Anoop Sharma
Subject: Re: [Help-bash] Bash is setting disposition of a signal, ignored upon entry to shell, to default
Date: Fri, 11 Jan 2013 11:52:04 +0530

I am testing on Ubuntu 12.04.1 LTS.

I have narrowed down this issue a bit more. The problem is not seen when I include a "#! /bin/bash" in the script or if I use the command "bash -c test_1.sh".

It is only seen when I rely on bash as ubuntu default command interpreter to work. I have verified that ubuntu does invoke the same bash as the command interpreter by including BASH_VERSION in the script.

Any idea what could be going wrong?

With Thanks,
Anoop

On Fri, Jan 11, 2013 at 1:13 AM, Chet Ramey <address@hidden> wrote:
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/


reply via email to

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