help-make
[Top][All Lists]
Advanced

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

Re: Questions about signal handling in GNU Make


From: Kaz Kylheku (gmake)
Subject: Re: Questions about signal handling in GNU Make
Date: Fri, 23 Jul 2021 14:40:33 -0700
User-agent: Roundcube Webmail/0.9.2

On 2021-07-23 14:19, Kaz Kylheku (gmake) wrote:
Secondly, build tools which open a file more than once
should not specify O_CREAT for the second and subsequent
times. The second and subsequent opens should expect
the file to exist, and fail otherwise.

Unfortunately, this is too naive, I apologize
for writing in haste.

A legitimate strategy for a tool is to write output
to a temporary file which is then renamed to the
destination as a last step.

Make, upon processing the interrupt signal, sees that
there is no file at all, nothing to delete.

Meanwhile, the tool reacts to the signal later, or
not at all, and executes through the rename system
call which creates the file.

There is also a race condition between make and the
very first open of the file, like this script

  #!/bin/sh
  sleep 5
  echo "hello" > $1

If this keeps executing while make processes the interrupt,
then we have the problem, even though there is just
a single open and write.

The correct behavior is to defer temporary file cleanup
of files until after no part of the job is running.

Or, perhaps to to it twice: once upon receipt of the
interrupt signal (because that might be the last
chance: make could be forcibly terminated after that;
it's kind of a "best effort").

Then, check those files again and re-delete any that
have re-appeared after the child jobs have been reaped.



reply via email to

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