From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M3Xxf-0000AX-9R for qemu-devel@nongnu.org; Mon, 11 May 2009 12:02:39 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M3XxZ-00009B-Tl for qemu-devel@nongnu.org; Mon, 11 May 2009 12:02:38 -0400 Received: from [199.232.76.173] (port=46514 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M3XxZ-000097-RK for qemu-devel@nongnu.org; Mon, 11 May 2009 12:02:33 -0400 Received: from mx20.gnu.org ([199.232.41.8]:58489) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1M3XxZ-0003qZ-CX for qemu-devel@nongnu.org; Mon, 11 May 2009 12:02:33 -0400 Received: from mail.codesourcery.com ([65.74.133.4]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M3XxY-0000fh-FC for qemu-devel@nongnu.org; Mon, 11 May 2009 12:02:32 -0400 From: Paul Brook Subject: Re: [Qemu-devel] [PATCH] suppress 'warn_unused_result' warning Date: Mon, 11 May 2009 17:02:28 +0100 References: <20090510.195335.-1303462317.imp@bsdimp.com> <20090511154226.GA29818@miranda.arrow> In-Reply-To: <20090511154226.GA29818@miranda.arrow> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200905111702.29635.paul@codesourcery.com> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, Stuart Brady On Monday 11 May 2009, Stuart Brady wrote: > On Sun, May 10, 2009 at 07:53:35PM -0600, M. Warner Losh wrote: > > When a signal is received and you are waiting for data, you get > > EINTR. If there's data available, then I believe the behavior is to > > return that data and not EINTR. That's the way Unix works. > > So if I do a read() from a file over NFS, and there's an awful lot of > latency (and perhaps even connection problems), and the process gets a > signal -- does that mean that the signal will only be delivered once > data is returned? The signal should be delivered immediately. Depending on various factors the kernel will either restart the syscall, fail with EINTR or return a partial read. > If not, then I would really start to wonder whether /all/ code dealing > with read(), write(), etc. should be written to cope with EINTR (and > also partial reads/writes?) regardless of whatever is done with threads > and signal masks, as doing otherwise seems only to be asking for trouble > at some point. (I'd be especially concerned about signals intended for > libraries that are not under the developer's control...) If your application uses signals (directly or indirectly via libraries) then all uses of read/write need to be tolerant of EINTR and partial reads. Paul