Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Date: Wed, 27 Dec 2000 14:11:19 -0500 From: Christopher Faylor To: Cygwin Subject: Re: Signal Handler Overwrites errno (or YACPP) Message-ID: <20001227141119.A1329@redhat.com> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: Cygwin References: <20001227115900 DOT B251 AT dothill DOT com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.11i In-Reply-To: <20001227115900.B251@dothill.com>; from Jason.Tishler@dothill.com on Wed, Dec 27, 2000 at 11:59:00AM -0500 On Wed, Dec 27, 2000 at 11:59:00AM -0500, Jason Tishler wrote: >On Fri, 10 Dec 1999 20:51:27 -0500, Chris Faylor wrote: >> I've checked in changes that seem to fix this. It was an interesting >> problem. read() was setting the EINTR errno but it was getting >> overwritten by a signal handler because I've changed the way signal >> handlers are called now. Although, actually, I would not be surprised >> to hear that this cropped up with B20.1 one time in a thousand too. >> >> So, now, in some situations, I save the errno for restoration when >> a signal handler returns. > >I am observing the same behavior as above but with select() and a SIGCHLD >handler when PostgreSQL has multiple TCP/IP connections. Unfortunately, >this causes PostgreSQL's postmaster to abort since it perceives that >select() has returned with an unexpected error. It's extremely unlikely that the year-old post that you copied has any bearing on this problem. I've written a simple test case to verify that cygwin is saving and restoring errno correctly and it seems to work fine. It returns this: ouch errno 2 -1 = select () errno 4 read ready The test case is included below. cgf #include #include #include #include #include #include void ouch (int sig) { puts ("ouch"); open("qwoeurpoqweuiroqpwiuroqpweiur", 0); fprintf (stderr, "errno %d\n", errno); } int main(int argc, char **argv) { int i, fds[2]; fd_set r; pipe(fds); signal(SIGCHLD, ouch); if (fork() == 0) { sleep (3); exit (0); } FD_ZERO(&r); FD_SET(fds[0], &r); /*close(fds[1]);*/ fprintf(stderr, "%d = select ()\n", select(fds[0] + 1, &r, NULL, NULL, NULL)); fprintf(stderr, "errno %d\n", errno); if (FD_ISSET(fds[0], &r)) fprintf(stderr, "read ready\n"); exit(0); } -- Want to unsubscribe from this list? Check out: http://cygwin.com/ml/#unsubscribe-simple