www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/2000/02/28/10:51:16

Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-developers-subscribe AT sourceware DOT cygnus DOT com>
List-Archive: <http://sourceware.cygnus.com/ml/cygwin-developers/>
List-Post: <mailto:cygwin-developers AT sourceware DOT cygnus DOT com>
List-Help: <mailto:cygwin-developers-help AT sourceware DOT cygnus DOT com>, <http://sourceware.cygnus.com/ml/#faqs>
Sender: cygwin-developers-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin-developers AT sourceware DOT cygnus DOT com
Message-ID: <779F20BCCE5AD31186A50008C75D99791716E9@SILLDN_MAIL1>
From: "Fifer, Eric" <EFifer AT sanwaint DOT com>
To: "'cygwin-developers AT sourceware DOT cygnus DOT com'"
<cygwin-developers AT sourceware DOT cygnus DOT com>
Subject: wait not setting errno to EINTR when interrupted
Date: Mon, 28 Feb 2000 15:59:19 -0000
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2448.0)

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_000_01BF8204.C0757E0E
Content-Type: text/plain;
	charset="iso-8859-1"


With the Feb-27 I'm seeing a interrupted wait() not setting errno to EINTR.

This is an example:

#include <unistd.h>
#include <stdio.h>
#include <sys/wait.h>
#include <signal.h>
#include <errno.h>

int onalrm() { printf("onalrm\n"); }

main()
{
    pid_t pid;
    int status = 0;

    if(fork() == 0) {
        sleep(10);
        exit(37);
    }

    signal(SIGALRM, onalrm);
    alarm(3);
    pid = wait(&status);
    printf("pid=%d status=%d errno=%d\n", pid, status, errno);
}

A run shows:

% ./a.exe
onalrm
pid=-1 status=0 errno=10

errno should be 4 (EINTR), *not* 10 (ECHILD, No Children).

I've attached a fix that works, but I'm not certain it is correct.

Eric



------_=_NextPart_000_01BF8204.C0757E0E
Content-Type: application/octet-stream;
	name="wait.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="wait.patch"

--- sigproc.cc-	Mon Feb 28 12:23:28 2000=0A=
+++ sigproc.cc	Mon Feb 28 15:48:56 2000=0A=
@@ -354,9 +354,10 @@ proc_subproc (DWORD what, DWORD val)=0A=
 	    {=0A=
 	      sip_printf ("waiting thread found no children");=0A=
 	      HANDLE oldw =3D w->next->ev;=0A=
-	      w->next->ev =3D NULL;=0A=
 	      if (clearing)=0A=
 		w->next->status =3D -1;		/* flag that a signal was received */=0A=
+	      else=0A=
+	        w->next->ev =3D NULL;=0A=
 	      if (!SetEvent (oldw))=0A=
 		system_printf ("couldn't wake up wait event %p, %E", oldw);=0A=
 	      w->next =3D w->next->next;=0A=

------_=_NextPart_000_01BF8204.C0757E0E--

- Raw text -


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