Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!apple!amdahl!krs From: krs@uts.amdahl.com (Kris Stephens [Hail Eris!]) Newsgroups: comp.unix.shell Subject: Re: Getting HUPed Message-ID: Date: 26 Mar 91 22:57:08 GMT References: <53767@mirror.tmc.com> <53902@mirror.tmc.com> Reply-To: krs@amdahl.uts.amdahl.com (Kris Stephens [Hail Eris!]) Distribution: na Organization: Amdahl Corporation, Sunnyvale CA Lines: 44 In article <53902@mirror.tmc.com> kiyun@mirror.UUCP (KiYun Roe) writes: >In article krs@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@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. ]