Date: Sat, 29 Jan 2005 17:00:39 +0300 From: Yar Tikhiy <yar@comp.chem.msu.su> To: Bruce Evans <bde@zeta.org.au> Cc: David Xu <davidxu@freebsd.org> Subject: Re: resolver un-conditionally restarts interrupted kevent Message-ID: <20050129140038.GA71245@comp.chem.msu.su> In-Reply-To: <20050128023756.E58087@delplex.bde.org> References: <20050127012401.GB48521@freefall.freebsd.org> <41F84C25.60903@freebsd.org> <20050127022459.GA63961@wnpgmb11dc1-164-159.dynamic.mts.net> <20050128023756.E58087@delplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050129140038.GA71245>