I have a problem, the attached program when compiled with the stuff in
/usr/openwin/lib on Solaris 2.4 works just fine. All the children are
/reaped and ^C does just the right thing.
However, and this is something of a mystery, when compiled with X11R6,
the child processes are not reaped and the signal handler for SIGCLD is
never called. Moreover, a ^C (after the children have died) produces
three <interrupted> messages -- it would appear that the threads that
X11R6 uses are causing some problems.
Can anyone shed light on this problem?
--
ISODE Consortium +44 181 332 9091
These are my opinions and have nothing to do with my employer.
-------------------
#include <stdio.h>
#include <signal.h>
#include <sys/wait.h>
#include <X11/Intrinsic.h>
#include <X11/Shell.h>
#include <X11/Xaw/Box.h>
#include <X11/Xaw/Label.h>
int tick = 5;
void h () {
int pid;
printf ("SIGCHLD\n");
while ((pid = waitpid (-1, NULL, WNOHANG|WUNTRACED)) > 0) {
printf ("reaped %d\n", pid);
tick--;
}
if (tick == 0) {
puts("got all the SIGCHLDs");
}
void intr () { printf ("<interrupted>\n"); }Quote:}
Widget top, box, label;
XtAppContext appctx;
Arg labelArgs[] = {
{XtNlabel, "hello"}
main (int argc, char *argv[])Quote:};
{
int i;
struct sigaction act;
int pid;
act.sa_handler = h;
sigemptyset (&act.sa_mask);
sigaction(SIGCHLD, &act, 0);
act.sa_handler = intr;
sigaction (SIGINT, &act, 0);
top = XtAppInitialize(&appctx,
"Foo",
NULL, 0,
&argc, argv, NULL, 0, 0);
box = XtCreateManagedWidget ("box", boxWidgetClass, top, NULL, 0);
label = XtCreateManagedWidget ("label", labelWidgetClass, box, labelArgs, 1);
XtRealizeWidget (top);
for (i = 0; i < 5; i++) {
switch (pid = fork()) {
case 0:
sleep(2+i/2);
printf ("dying\n");
exit(0);
break;
default:
printf ("child %d\n", pid);
break;
}
}
XtAppMainLoop (appctx);
Quote:}