Getting HUPed

Kris Stephens [Hail Eris!] krs at uts.amdahl.com
Wed Mar 27 08:57:08 AEST 1991


In article <53902 at mirror.tmc.com> kiyun at mirror.UUCP (KiYun Roe) writes:
>In article <d2wB01ev46cG00 at amdahl.uts.amdahl.com> krs at amdahl.uts.amdahl.com (Kris Stephens [Hail Eris!]) writes:
>>The thing about the trapped command is that you don't need to issue
>>an exit from within the command-series.  The sh (or ksh) will simply
>>execute the command on its merry way out.
>
>My experience is that if I don't put an exit within the trap command
>series, the script doesn't exit when it receives a signal.  It just
>cleans up the temp files and then continues to execute.  I use a trap
>handler so that I can clean-up before aborting on a signal, not to keep
>the signal from aborting the script.
>
>So, the issue is whether an exit in the trap 0 handler will cause any
>harm (loop), but I've never had any problem with that.

Okay, it ain't clear to me from reading ksh.1.  If I....

	trap 'echo "signalled"' 0 1 2 3 14 15

in a script (not in a function of the script), it *is* clear that 0
will echo "signalled" and exit.  It's not clear to me what will happen
on signals 1 2 3 14 15, though.

Should this work to (a) echo "signalled" and (b) exit, without recursion:

	trap 'echo "signalled"; exit' 0 1 2 3 14 15

where by "without recursion" I mean successive firings on the trap?
What would the exit code be if the trap is taken by execution of an
'exit 1' in the script?  Would it be 0 because the echo was a success?
Should I, instead, do:

	trap 'echo "signalled"' 0
	trap 'echo "signalled"; exit' 1 2 3 14 15

to avoid a possible recursion and protect the exit code?

Anyone *really* know?
...Kris
-- 
Kristopher Stephens, | (408-746-6047) | krs at uts.amdahl.com | KC6DFS
Amdahl Corporation   |                |                    |
     [The opinions expressed above are mine, solely, and do not    ]
     [necessarily reflect the opinions or policies of Amdahl Corp. ]



More information about the Comp.unix.shell mailing list