From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45195) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vfv1d-0004Ie-Lu for qemu-devel@nongnu.org; Mon, 11 Nov 2013 12:11:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vfv1Y-0003yH-Q8 for qemu-devel@nongnu.org; Mon, 11 Nov 2013 12:11:45 -0500 Received: from mail-la0-f50.google.com ([209.85.215.50]:60367) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vfv1Y-0003xw-JE for qemu-devel@nongnu.org; Mon, 11 Nov 2013 12:11:40 -0500 Received: by mail-la0-f50.google.com with SMTP id eo20so4137584lab.23 for ; Mon, 11 Nov 2013 09:11:39 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <52810AEA.5020806@redhat.com> From: Peter Maydell Date: Mon, 11 Nov 2013 17:11:18 +0000 Message-ID: Content-Type: text/plain; charset=UTF-8 Subject: Re: [Qemu-devel] audit needed for signal handlers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: "qemu-devel@nongnu.org" On 11 November 2013 16:56, Anthony Liguori wrote: > On Mon, Nov 11, 2013 at 8:50 AM, Eric Blake wrote: >> Here's a hint: ioctl() can clobber errno. But if a signal handler is >> called in the middle of other code that is using errno, then the handler >> MUST restore the value of errno before returning, if it is to guarantee >> that the interrupted context won't be corrupted. > > Isn't this precisely why EINTR exists? EINTR won't help you in the case like: ret = some_syscall(); [execution returns from syscall, with errno set to X] [signal happens here; handler trashes errno] if (ret < 0) { use errno; } EINTR exists mostly because properly resuming syscalls was too hard for Bell Labs :-) -- PMM