From owner-freebsd-arch@FreeBSD.ORG Sat Jan 29 14:00:48 2005 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6784616A4CE; Sat, 29 Jan 2005 14:00:48 +0000 (GMT) Received: from comp.chem.msu.su (comp.chem.msu.su [158.250.32.97]) by mx1.FreeBSD.org (Postfix) with ESMTP id 40E2343D3F; Sat, 29 Jan 2005 14:00:47 +0000 (GMT) (envelope-from yar@comp.chem.msu.su) Received: from comp.chem.msu.su (localhost [127.0.0.1]) by comp.chem.msu.su (8.12.9p2/8.12.9) with ESMTP id j0TE0hnZ080636; Sat, 29 Jan 2005 17:00:43 +0300 (MSK) (envelope-from yar@comp.chem.msu.su) Received: (from yar@localhost) by comp.chem.msu.su (8.12.9p2/8.12.9/Submit) id j0TE0dXF080630; Sat, 29 Jan 2005 17:00:39 +0300 (MSK) (envelope-from yar) Date: Sat, 29 Jan 2005 17:00:39 +0300 From: Yar Tikhiy To: Bruce Evans Message-ID: <20050129140038.GA71245@comp.chem.msu.su> References: <20050127012401.GB48521@freefall.freebsd.org> <41F84C25.60903@freebsd.org> <20050127022459.GA63961@wnpgmb11dc1-164-159.dynamic.mts.net> <20050128023756.E58087@delplex.bde.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050128023756.E58087@delplex.bde.org> User-Agent: Mutt/1.5.6i cc: arch@freebsd.org cc: "Christian S.J. Peron" cc: David Xu Subject: Re: resolver un-conditionally restarts interrupted kevent X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Jan 2005 14:00:48 -0000 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