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: Wed, 20 Jul 2022 07:26:39 +0900

2022年7月20日(水) 0:25 Masahiro Yamada <masahiroy@kernel.org>:
> On Tue, Jul 19, 2022 at 6:56 PM Koichi Murase <myoga.murase@gmail.com> wrote:
> > I'm not sure if we should clean up temporary files on the signals in
> > general. For example, it is also possible that we would like to check
> > the intermediate state of the processing after canceling the command
> > by INT, for which we want to preserve the intermediate state of the
> > temporary files. Naively, I would expect programs to terminate without
> > changing the current status of the filesystem by default.
>
> Actually, my main motivation is to make the Linux kernel build system
> (written by GNU Make) more reliable.

Maybe I have confused you, but I'm not trying to say that you
shouldn't clean up the temporary files. In the above part, I am
talking about the "default" behavior in "general" cases. The example
of GNU make you provided is just a specific case. In general, the
expected behavior is case by case, so it would be hard to expect the
default behavior to be exactly what you expect for this specific case.
You would finally need to set things up case by case for the expected
behavior which varies case by case.

> Why does "trap trapint INT"  make the difference?

With an INT trap, Bash will not exit by the INT signal unless the user
explicitly runs exit or kill. Without the INT trap, Bash might exit at
the point the user doesn't expect. I've checked the behavior for the
present case again. You are interrupting the EXIT trap (i.e., "rm -rf
tmp") by sending INT, but the EXIT trap will not be called again when
it is interrupted by INT.

--
Koichi



reply via email to

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