Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: using trap function to cleanup and exit?



On Sun, 2022-04-10 at 11:46 -0400, Greg Klanderman wrote:
> TRAPTERM () {
>   echo "in TRAPTERM"
>   cleanup TERM
>   exit $(( 128 + $1 ))
> }

I haven't gone through this in great detail, so no guarantee this causes
everything to spring into life, but just to note that normal service
here would be obtained if you turn that "exit" into "return".  As
described in the Trap Functions in zshmisc, that's specially handled so
that the shell knows you want to continue to exit in a similar way to if
SIGTERM had been received without the trap function.

pws





Messages sorted by: Reverse Date, Date, Thread, Author