Re: [PATCH] style guide note about writing signal handlers
Hi!
> > Patch with note about writing signal handlers attached.
> >
> > Garrett feel free to rewrite it to match the rest of the style guide.
>
> Patch is fine minus one typo (s/singal/signal/). The more complicated
> part is that the majority of our libltp based infrastructure does use
> non-async safe functions in signal handlers to crash and burn
> testcases (tst_sig is built on tst_brkm, which uses fprintf, fflush,
> etc).
Well yes the libltp interface is far too complicated and would probably
gain from simplification, it would be much easier to do it correctly
then. The real problem is a number of testcases using it.
The downside of signal handler and non-async safe functions is that you
will never know, when they fail, they usually fail with relatively small
probability and on some system they run just fine, because of different
libc internals etc. Such behaviour often results in false-possitive
regressions. And the only way to avoid this is not to complicate your
signal handler.
If I remember correctly the problem with printf is that it may use
malloc for allocating the buffer, that if called, while there is malloc
or free running in the main loop, could cause problems. Which is not
likely, at least most of the time.
> I agree with you that doing stuff in signal handlers is non-kosher,
> and some testcases should be fixed, but some concession might need to
> be made for the crash and burn logic in other testcases and the
(Continue reading)