Re: Fix signal handler
- From
Jeff King <peff@peff.net>
- Date
- Feb 2, 2010, 20:58 UTC
- Message-ID
- <20100202205849.GA14385@sigill.intra.peff.net>
- In-Reply-To
- <4B684F5F.7020409@web.de>
On Tue, Feb 02, 2010 at 05:14:23PM +0100, Markus Elfring wrote:
Show 8 quoted lines
> The function "early_output" that is set as a signal handler by the > function "setup_early_output" contains a simple looking instruction. > [...] > A global variable gets a function pointer assigned. > [...] > I find that this approach does not fit to standard rules because the > data type "sig_atomic_t" is the only type that can be safely used for > global write access in signal handlers.
No, it's not a sig_atomic_t, but it is assignment of a single function pointer that is properly declared as volatile. Is this actually a problem on any known system?
If you want to nit-pick, there are much worse cases. For example, in diff.c, we do quite a bit of work in remove_tempfile_on_signal. It assumes that char* assignment is atomic, but nothing is even marked as volatile. But again, is this actually a problem on any system?
You will find that most git developers care about real problems that can be demonstrated on real systems. Standards can be a useful guide, but they can be too loose (e.g., we run on some non-POSIX systems) as well as too restrictive. What matters is what actually runs in practice.
If you can demonstrate a practical problem and provide a patch, then I am sure people would be happy to read it.
-Peff