help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Question] Reliable way to clean up a directory in EXIT trap


From: Koichi Murase
Subject: Re: [Question] Reliable way to clean up a directory in EXIT trap
Date: Thu, 21 Jul 2022 07:48:45 +0900

2022年7月20日(水) 13:20 Masahiro Yamada <masahiroy@kernel.org>:
> If Bash receives SIGINT while executing the EXIT trap,
> it will run the command 'echo ouch', but never return
> to the point where it was interrupted.
>
> This is different from how interrupt handlers are processed.

What does "the point where it was interrupted" mean? If I literally
read it, it doesn't seem to be correct as far as I try.

$ bash -c 'trapint() { echo INT; }; trap trapint INT; trapexit() {
echo EXIT1; sleep 3; echo EXIT2; }; trap trapexit EXIT; exit'
EXIT1
^CINT
EXIT2

> I think Bash can improve this point:
> The EXIT handler should not be interrupted by any signal.

I don't think it makes sense. If all the signals are disabled in
running the EXIT handler, there is no way to stop the EXIT handler
when it hangs other than sending SIGKILL. Even if you might see this
useful for your case, I hardly think it should be the default.

--
Koichi



reply via email to

[Prev in Thread] Current Thread [Next in Thread]