resolver un-conditionally restarts interrupted kevent

Yar Tikhiy yar at comp.chem.msu.su
Sat Jan 29 06:00:48 PST 2005


On Fri, Jan 28, 2005 at 03:07:31AM +1100, Bruce Evans wrote:
> 
> Just setting flags in signal handlers is very hard to implement correctly.
> SA_RESTART must not be used for any signal handler, and EINTR must be
> handled for all syscalls and perhaps some library functions that would
> otherwise be restarted.  ping attempts this but doesn't succeed because
> the resolver library doesn't cooperate.  top's signal handling was
> broken by changing its signal handler[s] to just set a flag without
> even attempting this.  So SIGINT doesn't kill top when top is blocked
> in read().

BTW, even BSD stdio isn't friendly to signals w/o SA_RESTART.  I
ran into a rather nasty bug resulting in not less than data loss
when a stdio call was interrupted and returned EINTR.  I filed a
PR on that, kern/76398, including a simple test program.

It seems that programs using signals w/o SA_RESTART should block
them for most of time and explicitly allow their delivery in carefully
selected windows of safety.

A significantly worse (but easier to implement) workaround could
be to block such signals for the time spent in unsafe library calls.

-- 
Yar


More information about the freebsd-arch mailing list