Subject: Re: [PATCH 1/1] fetch: fix deadlock when cleaning up lockfiles in async signals

From: Taylor Blau <[email-masked]>
Date: Mon, 10 Jan 2022 21:11:20 -0500

On Sat, Jan 08, 2022 at 10:54:35AM +0000, Phillip Wood wrote:
> > But is unlink() safe as-is? I'm not so sure. Reading signal-safety(7),
> > it's clearly on the list of functions that are OK to call. But reading
> > the errno section:
> >
> > (snip)
> >
> > We certainly not doing that, though that's nothing new, and so I wonder
> > why it doesn't seem to be an issue in practice.
>
> Because in this case we re-raise the signal and exit it does not matter if
> unlink() clobbers errno. If instead the program were to continue after
> handling the signal then we would have to save and restore errno to avoid
> interfering with the code that was running when the signal handler was
> called.

That makes perfect sense to me. Thanks for a clear explanation.

Taylor