Subject: Simple test case of SIGCHLD hang
From: [email-masked] (Chris Faylor)

17 Jun 1997 19:50:52 -0700
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
Original-To: [email-masked], [email-masked]
Original-Sender: [email-masked]

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
"[email-masked]" with one line of text: "help".