Received: from PACIFIC-CARRIER-ANNEX.MIT.EDU by po7.MIT.EDU (5.61/4.7) id AA01359; Tue, 20 Feb 96 14:34:45 EST
Received: from YAZ-PISTACHIO.MIT.EDU by MIT.EDU with SMTP
	id AA18438; Tue, 20 Feb 96 14:34:15 EST
Received: by yaz-pistachio.MIT.EDU (5.57/4.7) id AA11115; Tue, 20 Feb 96 14:34:43 -0500
Message-Id: <9602201934.AA11115@yaz-pistachio.MIT.EDU>
To: green@cygnus.com
Cc: proven@MIT.EDU
Subject: Re: more pthreads questions 
In-Reply-To: Your message of "Wed, 14 Feb 1996 14:40:29 EST."
             <199602141940.OAA19380@hoser.cygnus.com> 
Date: Tue, 20 Feb 1996 14:34:42 EST
From: Christopher Provenzano  <proven@MIT.EDU>


> 
> My multithreaded Guile is getting cooler by the day. The garbage collector
> is bahaving properly, but I still have some signal handling troubles
> to work out.
> 
> Here's a little C program that doesn't behave properly when I build
> and link against 1.60 beta 4.1. It hangs under Linux 1.2.13.
> Any ideas? 
> 
> ---- cut here ----------------------------------------------------
> #include <stdio.h>
> #include <signal.h>
> #include <sys/wait.h>
> 
> int gotSignal = 0;
> 
> sigProc(sig)
>      int sig;
> {
>   gotSignal = 1;
> }
> 
> main()
> {
>   int pid, sts;
>   (void) signal(SIGCHLD, sigProc);
>   pid = vfork();
>   if (pid <  0) {
>     exit(1);
>   } else if (pid == 0) {
>     (void) signal(SIGCHLD, SIG_DFL);
>     _exit(0);
>   } else {
>     (void) wait(&sts);
>   }
>   printf("%d\n", gotSignal);
>   exit((gotSignal) ? 0 : 1);
> }
> 
> ---- cut here ----------------------------------------------------
> 
> Anthony
> 
The problem is that you are stomping on the signal handler that the
thread package is using to intercept SIGCHLD. Use pthread_signal() 
when setting up the signal handler. I haven't written the wrapper for 
signal() yet because unlike most syscalls which I can use a template, 
signal() does some extra processing in the asm code which I have to 
figure out for each platform. 

CAP
