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

Re: trap .. EXIT doesn't execute when exit is due to a signal



On Feb 12,  3:04pm, Dan Nelson wrote:
} Subject: Re: trap .. EXIT doesn't execute when exit is due to a signal
}
} In the last episode (Feb 12), Matthias B. said:
} > trap ... EXIT doesn't execute ... when the shell is terminated due to
} > a signal (e.g. Ctrl-C). I think this is a bug. It's certainly
} > undesirable, because it causes cleanup tasks to not be executed. Bash
} > doesn't have this problem.
} 
} zsh-users 3513 describes what is happening here, I think.  Ash and
} /Solaris bin/sh have the same behaviour.

Yep, that's exactly it.

It just occured to me that it may very well be the case that bash is
using the POSIX atexit() handler to execute its exit traps, which I
believe would handle the situation described in 3513 without having
to do any special handling of SIGINT.

However, I'm not positive that covers all the cases in which zsh runs
the exit trap, and it'd have to be used carefully to be sure the exit
trap wasn't run more than once.



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