[ccache] ccache interrupt handling bug

Eitan Adler lists at eitanadler.com
Wed Aug 19 04:33:44 UTC 2015

On 18 August 2015 at 21:17, Tom Lane <tgl at sss.pgh.pa.us> wrote:
> Joel Rosdahl <joel at rosdahl.net> writes:
>> Tom Lane <tgl at sss.pgh.pa.us> wrote:
>>> Actually, that's a bug not just a cosmetic problem, because it introduces
>>> a race condition.
>> Yes, sounds like a race condition that could happen.
>> I just pushed this change as a fix:
>> https://git.samba.org/?p=ccache.git;a=commitdiff;h=4fdb9580fedac9669508bef0837f46f1e9310e24.
>> Opinions on it are welcome.
> Hm.  In principle there are still race conditions here: consider what
> happens if the SIGINT is received between fork() and storing the PID
> into *pid, or after waitpid() and before clearing *pid.

FWIW the current signal handler is not fully safe.  In particular, it
modifies variables which are not volatile sig_atomic_t (see section of the C11 standard for more details).  The call to unlink()
is safe per POSIX but is not safe according to strict C semantics (see
Similarly, _Exit is required by C, though _exit is safe per POSIX.

Eitan Adler

More information about the ccache mailing list