From owner-freebsd-arch@FreeBSD.ORG Sat Sep 1 22:40:27 2007 Return-Path: Delivered-To: freebsd-arch@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BF5AE16A420; Sat, 1 Sep 2007 22:40:27 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (meestal-mk5.stack.nl [IPv6:2001:610:1108:5010::149]) by mx1.freebsd.org (Postfix) with ESMTP id 67ECE13C4B0; Sat, 1 Sep 2007 22:40:27 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id 1E79A3FDE9; Sun, 2 Sep 2007 00:40:26 +0200 (CEST) Received: by snail.stack.nl (Postfix, from userid 1677) id 0E650228C0; Sun, 2 Sep 2007 00:40:26 +0200 (CEST) Date: Sun, 2 Sep 2007 00:40:26 +0200 From: Jilles Tjoelker To: Joe Marcus Clarke Message-ID: <20070901224025.GA97796@stack.nl> References: <1188600721.1255.11.camel@shumai.marcuscom.com> <20070901112600.GA33832@stack.nl> <1188660782.41727.5.camel@shumai.marcuscom.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1188660782.41727.5.camel@shumai.marcuscom.com> X-Operating-System: FreeBSD 6.2-STABLE i386 User-Agent: Mutt/1.5.16 (2007-06-09) Cc: freebsd-arch@FreeBSD.org Subject: Re: Understanding interrupted system calls X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 Sep 2007 22:40:27 -0000 On Sat, Sep 01, 2007 at 11:33:02AM -0400, Joe Marcus Clarke wrote: > However, I'm curious as to my other point in this thread. Why should > one need to re-register the default signal handlers to get a syscall to > return EINTR? Or should ERESTART be caught and turned into EINTR then > return to the caller (as in kern_connect())? It is intended that most blocking system calls are not interrupted by signals. This saves the programmer some checks on EINTR. (Note that this is only really useful if the program uses signal handlers which do something meaningful other than setting a flag or doing some simple cleanup and terminating the process. Such signal handlers are rarely safe.) Some system calls, e.g. connect(), read/write/etc that have already committed some data and under BSD also select/poll/kqueue do not restart and always return EINTR or partial success. In the kernel code, this appears as changing ERESTART to EINTR. -- Jilles Tjoelker