chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-hackers] [PATCH] Handle EINTR properly in process-wait (was


From: Peter Bex
Subject: Re: [Chicken-hackers] [PATCH] Handle EINTR properly in process-wait (was: [PATCH] Handle EINTR properly in getc())
Date: Wed, 3 Oct 2012 22:29:44 +0200
User-agent: Mutt/1.4.2.3i

On Wed, Oct 03, 2012 at 09:10:09PM +0200, Peter Bex wrote:
> Hi all,
> 
> I got some strange results when registering a signal handler for sigchld,
> as I documented here:
> http://lists.nongnu.org/archive/html/chicken-users/2012-10/msg00009.html
> 
> It turns out that this is caused by faulty EINTR handling.  On Linux and
> OpenBSD this apparently is not an issue, but on NetBSD registering sigchld
> causes the program in my message to return from the child before reading
> has finished (but only about 9 times out of 10).  This causes SIGCHLD to
> be delivered, which means the read action gets interrupted with EINTR.

There's another EINTR-related error which is easily triggered on NetBSD
by this short program:


(use posix)
(set-signal-handler! signal/chld void)
(process-wait (process-fork void))


This will result in the following error message:
Error: (process-wait) waiting for child process failed - Interrupted system 
call: 20331

After some consideration, I think this particular situation should simply
cause a retry to happen, just like with reading.  I'm unsure the call to
##sys#dispatch-interrupt is required, I just cargo-culted it from the
other _eintr checks I saw.

I've now added a test since this one is really easy to trigger, and the
test is simply a combined test for both bugs so it doesn't take up too
much space in the test suite for a mostly NetBSD-specific test.

This patch is cumulative; it does not include the previous patch for
getc's EINTR bug.

Cheers,
Peter
-- 
http://sjamaan.ath.cx
--
"The process of preparing programs for a digital computer
 is especially attractive, not only because it can be economically
 and scientifically rewarding, but also because it can be an aesthetic
 experience much like composing poetry or music."
                                                        -- Donald Knuth

Attachment: 0001-Fix-handling-of-EINTR-in-process-wait-by-retrying.-A.patch
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]