wait not setting errno to EINTR when interrupted

Fifer, Eric EFifer@sanwaint.com
Mon Feb 28 08:00:00 GMT 2000


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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: wait.patch
Type: text/x-diff
Size: 522 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-developers/attachments/20000228/5102fec0/attachment.bin>


More information about the Cygwin-developers mailing list