delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/12/27/14:12:20

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
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 <cgf AT redhat DOT com>
To: Cygwin <cygwin AT cygwin DOT com>
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 <cygwin AT cygwin DOT com>
References: <20001227115900 DOT B251 AT dothill DOT com>
Mime-Version: 1.0
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 <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/time.h>
#include <errno.h>
#include <signal.h>

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019