On Sat, Jul 24, 2021 at 11:57 PM Kaz Kylheku (gmake)
<[email protected]> wrote:
>
> On 2021-07-24 06:21, Masahiro Yamada wrote:
> > To avoid the race on the tool side, as you mentioned,
> > we can write to a tmpfile, and rename it as a last step.
>
> But, no we can't!
>
> This situation is not a problem only in the case when
> the recipe has one step to perform.
>
> What if it is like this?
>
>     out: in
>         step1 in out
>         step2 out
>
> step1 performs the temporary rename dance to atomically
> create "out", while make is handling the interrupt again.
>
> make doesn't see "out" so doesn't remove anything, but
> then moments later, step1 executes a rename of a temporary
> file to "out" before terminating.
>
> Now there is a half-baked but up-to-date out, because
> step2 wasn't executed.
>

I said that renaming "as a last step".

So, the recipe that invokes multiple commands
should look like follows:


out: in
        step1 in out.tmp
        step2 out.tmp
        mv out.tmp out



-- 
Best Regards
Masahiro Yamada

Reply via email to