This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Simple test case of SIGCHLD hang


I've whittled down zsh's behavior to a simple test case which illustrates
the 'hang' I experience in zsh and, I expect, what others experience in
pdksh.

It apparently has something to do with signal masking.  I haven't looked
at the cygwin code in question yet, but I'm sure that it is extremely
difficult, if not impossible to fix.  Which means that Sergey should have
a patch available in an hour or so...  :-)

Btw, on UNIX the code below prints:

exiting from child
sleeping
in child handler
pid returned = 4901
status returned = 0

On gnuwin32, I get:
exiting from child
sleeping
(hang)

The hang is actually understandable since all signals are blocked, even
SIGINT.

-cgf

#include <stdio.h>
#include <signal.h>
#include <sys/wait.h>
void child(int sig)
{
    int pid, status;
    fputs("in child handler\n", stderr);
    pid = waitpid(-1, &status, WNOHANG|WUNTRACED);
    fprintf(stderr, "pid returned = %d\n", pid);
    fprintf(stderr, "status returned = %x\n", status);
    return;
}

main(int argc, char **argv)
{
    sigset_t set, oset;

    sigfillset(&set);
    sigprocmask(SIG_BLOCK, &set, &oset);
    setbuf(stderr, NULL);
    signal(SIGCHLD, child);
    if (fork() == 0) {
	fputs("exiting from child\n", stderr);
	exit(0);
    }

    sleep(1);
    fputs("sleeping\n", stderr);
    sleep(3);
    sigdelset(&set, SIGCHLD);
    sigsuspend(&set);
    exit(0);
}
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]