* SIGCHLD signal problem in OSF1 3.0
@ 1995-04-06 4:00 David Yeung
1995-04-12 4:00 ` Jon Jenkins
0 siblings, 1 reply; 2+ messages in thread
From: David Yeung @ 1995-04-06 4:00 UTC (permalink / raw)
Hi
I am writing a problem trying to catch the SIGCHLD signal when any of
its child processes dies. But I find that some SIGCHLD signals are lost
if more than one child processes terminate simultaneously.
Here is my test program:
================================================
#include <stdio.h>
#include <sys/types.h>
#include <signal.h>
void func1 ();
main()
{
pid_t pid;
int i;
sigset(SIGCLD, func1);
for (i=0;i<10;i++) {
if ((pid = fork ()) == 0) {
sleep (1);
exit (1);
}
printf ("pid = %d\n", (int)pid);
}
for (;;);
}
void func1 ()
{
pid_t pid;
pid = wait (NULL);
sigset(SIGCHLD, func1);
printf ("func1 pid = %d\n", (int)pid);
}
=================================================
The program forks a number of processes and those child processes
terminates at around the same time. But the signal handler (func1)
can only catch one or two SIGCHLD signal. The others are lost. If
I change the statement "sleep (1)" to "sleep (i+1)", i.e, the
child processes are not terminated at the same time, then all
SIGCHLD signals are catched.
Does anyone know how to resolve this problem? This problem does
not appear in SGI and SUN Unix.
Thanks in advance.
David Yeung
--
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: SIGCHLD signal problem in OSF1 3.0
1995-04-06 4:00 SIGCHLD signal problem in OSF1 3.0 David Yeung
@ 1995-04-12 4:00 ` Jon Jenkins
0 siblings, 0 replies; 2+ messages in thread
From: Jon Jenkins @ 1995-04-12 4:00 UTC (permalink / raw)
David Yeung (yeung@ncar.ucar.edu) wrote:
: Hi
: I am writing a problem trying to catch the SIGCHLD signal when any of
: its child processes dies. But I find that some SIGCHLD signals are lost
: if more than one child processes terminate simultaneously.
This is traditional UNIX problem. For a refernece read
Richard Stevens Book " Advanced Programming in the UNIX Environment"
WRS says that "if a blocked signal (blocked automatically
during signal delivery) then POSIX.1 allows for the
signal to be delivered either once or more than
once. If the signal is delivered more than once
we say that the signals are queued. Most UNIX
systems do "not" (his emphasis) do not queue
signals. Instead the UNIX kernal just delivers
the signal once. "
As to whether OSF/1 queues
signals of the same type I dont know
the man pages are silent on this issue.
Perhaps some of the OSF/1 signal people
would comment. They might also like to
comment on the differences between
linking with the two versions (sys5 and bsd)
versions of the library.
He [WRS] goes on to say that
"The manual pages for System V claimed that SIGCLD
signal was queued, but it realy wasn't. Instead the
signal was regenerated by the kernel as described
in Section 10.7" (sse the discussion below and code frag)
"The sigaction manual page in AT&T [1990e]
claims that the SA_SIGINFO flag (Figure 10.5)
causes signals to be reliably queued. This is
wrong. Apparently this feature exists within
the kernel, but it is not enabled in SVR4."
Accoring to what is said that fact that
it works onother systems may be a "fluke"
of ther OS timing or OS strategy rather
than a feature. However he does also say
that the SYSV semantics of SIGCLD (NOT SIGCHLD)
are such that if it is placed after the call
to wait() then the kernel will check
if any other children have died
and will recursively call the handler.
This avoids the window problem
of the older unreliable signals.
i.e. func1 should look like:
void func1 ()
{
pid_t pid;
pid = wait (NULL);
printf ("func1 pid = %d\n", (int)pid);
sigset(SIGCHLD, func1);
}
But this dont work either no matter
which library is linked ;-(
--
----------------------------------------------------------------------
Name: Dr Jon Jenkins
Location: Digital Equipment Corp, NaC,
Burnett Place, Research Park,
Bond University, Gold Coast
QLD, AUSTRALIA 4229
Phone: 61-75-75-0151
Fax: 61-75-75-0100
Internet: jenkinsj@ozy.dec.com
Close Proximity: "HEY YOU !!!"
The opinions expressed above are entirely personal and do not
reflect the corporate policy of DEC or the opinions of DEC management.
-----------------------------------------------------------------------
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1995-04-12 4:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1995-04-06 4:00 SIGCHLD signal problem in OSF1 3.0 David Yeung
1995-04-12 4:00 ` Jon Jenkins
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox