delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/06/17/19:50:52

From: cgf AT bbc DOT com (Chris Faylor)
Subject: Simple test case of SIGCHLD hang
17 Jun 1997 19:50:52 -0700 :
Approved: cygnus DOT gnu-win32 AT cygnus DOT com
Distribution: cygnus
Message-ID: <199706172011.QAA04920.cygnus.gnu-win32@hardy.bbc.com>
Original-To: gnu-win32 AT cygnus DOT com, sos AT prospect DOT com DOT ru
Original-Sender: owner-gnu-win32 AT cygnus DOT com

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 AT cygnus DOT com" with one line of text: "help".

- Raw text -


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