Unix Programming - Does the bash shell store signal traps between sessions?

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > November 2005 > Does the bash shell store signal traps between sessions?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Does the bash shell store signal traps between sessions?
50295@web.de

2005-11-08, 6:29 pm

Hi -

Before I typed trap "" HUP, all processes started from the bash shell
are termiated with the shell. Now, processes no longer die with the
shell. Are trap commands signal traps between sessions?

Thanks,

- Olumide

Michael Tosch

2005-11-08, 6:29 pm

50295@web.de wrote:
> Hi -
>
> Before I typed trap "" HUP, all processes started from the bash shell
> are termiated with the shell. Now, processes no longer die with the
> shell. Are trap commands signal traps between sessions?
>
> Thanks,
>


No, every login session is individual.
Signal definition is gone as soon the bash login shell terminates.


--
Michael Tosch @ hp : com
50295@web.de

2005-11-08, 6:29 pm

Michael Tosch wrote:

> No, every login session is individual.
> Signal definition is gone as soon the bash login shell terminates.
>


Thanks. It appears there is a world of difference between terminating
the shell via the close icon (on the upper right corner), and merely
typing exit. Using the latter on a RedHat machine, the (X windows)
application I started did not terminate even though no signal trap was
"installed". I wonder why ...

Michael Tosch

2005-11-08, 6:29 pm

50295@web.de wrote:
> Michael Tosch wrote:
>
>
>
>
> Thanks. It appears there is a world of difference between terminating
> the shell via the close icon (on the upper right corner), and merely
> typing exit. Using the latter on a RedHat machine, the (X windows)
> application I started did not terminate even though no signal trap was
> "installed". I wonder why ...
>


Probably a bug in your X-terminal tool.
Try "xterm" which is based on old but mature code.

--
Michael Tosch @ hp : com
50295@web.de

2005-11-08, 6:29 pm

Michael Tosch wrote:

> Probably a bug in your X-terminal tool.
> Try "xterm" which is based on old but mature code.


I'm using bash. You're not suggesting bash 3.00.15(1) is this buggy are
you? ;) . Anyway, same thing happend with xterm. Here's what I did:

- start xterm
- in xterm, run/type: "xcalc &"
- in xterm, run/type: "exit"
--> xcalc continues to run!!!

Is this expected behaviour?

Michael Tosch

2005-11-08, 6:29 pm

50295@web.de wrote:
> Michael Tosch wrote:
>
>
>
>
> I'm using bash. You're not suggesting bash 3.00.15(1) is this buggy are
> you? ;) . Anyway, same thing happend with xterm. Here's what I did:
>
> - start xterm
> - in xterm, run/type: "xcalc &"
> - in xterm, run/type: "exit"
> --> xcalc continues to run!!!
>
> Is this expected behaviour?
>


Yes, this is normal behaviour.
Therefore, your desktop will kill each X-Window separately
when you quit it (logout).

If you want background jobs to be killed at shell exit,
you can do

trap "kill %1" 0
xcalc &

which will kill its first background job.

In bash you can do

trap "jobs -p | xargs kill" 0

which will kill all of its background jobs.


--
Michael Tosch @ hp : com
50295@web.de

2005-11-17, 6:13 pm


Michael Tosch wrote:
> 50295@web.de wrote:


>
> Yes, this is normal behaviour.
> Therefore, your desktop will kill each X-Window separately
> when you quit it (logout).


I hate to sound like a broken record, but why isn't the HUP signal sent
to xcalc when I exited the shell in the above scenario???

Valentin Nechayev

2005-11-18, 7:50 am


Thu, Nov 17, 2005 at 08:03:59, 50295 (50295@web.de) wrote about "Does the bash shell store signal traps between sessions?":

[vbcol=seagreen]
> I hate to sound like a broken record, but why isn't the HUP signal sent
> to xcalc when I exited the shell in the above scenario???


This is shell behavior, not xcalc.
Compare with variant: run xterm, xcalc&, and close xterm by window
manager. xcalc will disappear.
I can't detect now exact mechanism used by bash but ktrace shows
bash calls tcsetpgrp() and setpgid() on exit.


-netch-
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com