Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Child signal behaviour on HPUX

Reply
Thread Tools

Child signal behaviour on HPUX

 
 
Jorge
Guest
Posts: n/a
 
      07-01-2003
All,

I've got a process that creates some children and want to be alerted
when they die. To do this, the SIGCHLD signal is registered in the
process using sigaction to jump to a subprogram as soon as it's
received.

The problem comes when many children exit at the same time and their
father seems to miss some of them. This happens quite often, but not
always.

Why are the signals being missed? I'm pretty sure it's something with
the flags on sigaction, but I've tryed several options and it's always
the same.

I appreciate your suggestions. Thanks in advance.

PS: Perl 2.5.1, hpux 11.00

CODE----------------

#!/bin/env perl

use strict;
use POSIX;

# empty set
my $sigset = POSIX::SigSet->new;

# sigaction structure
my $newaction = POSIX::SigAction->new( 'my_handler', $sigset,
SA_NODEFER);
my $oldaction = POSIX::SigAction->new;
my $return;

sub my_handler
{
my($sig) = @_;
my($hpid) = wait();
$return = POSIX::WEXITSTATUS($?);
print "Im $$. Caught a SIG$sig from $hpid returning $return\n";
sleep(10);
print "Ending handler of $hpid\n";
}

sigaction(SIGCHLD, $newaction, $oldaction);

if (!fork())
{
print "Im $$ sleeping 3 s\n";
sleep(3);
print "Im $$ returning 7\n";
exit(7);
}
if (!fork())
{
print "Im $$ sleeping 3 s\n";
sleep(3);
print "Im $$ returning 7\n";
exit(7);
}
if (!fork())
{
print "Im $$ sleeping 3 s\n";
sleep(3);
print "Im $$ returning 7\n";
exit(7);
}
if (!fork())
{
print "Im $$ sleeping 3 s\n";
sleep(3);
print "Im $$ returning 7\n";
exit(7);
}
if (!fork())
{
print "Im $$ sleeping 3 s\n";
sleep(3);
print "Im $$ returning 7\n";
exit(7);
}
print "Im father process $$\n";
sleep(20);
exit(0);

SOME CUT&PASTE FROM THE TERM---------- as you can see only 4 signals
out of 5 are detected

$ dwmanager_v4_en.pl
Im 6406 sleeping 3 s
Im 6407 sleeping 3 s
Im 6408 sleeping 3 s
Im 6409 sleeping 3 s
Im father process 6405
Im 6410 sleeping 3 s
Im 6406 returning 7
Im 6405. Caught a SIGCHLD from 6406 returning 7
Im 6408 returning 7
Im 6407 returning 7
Im 6409 returning 7
Im 6405. Caught a SIGCHLD from 6409 returning 7
Im 6410 returning 7
Im 6405. Caught a SIGCHLD from 6408 returning 7
Im 6405. Caught a SIGCHLD from 6410 returning 7
Ending handler of 6410
Ending handler of 6408
Ending handler of 6409
Ending handler of 6406
$
 
Reply With Quote
 
 
 
 
Bryan Castillo
Guest
Posts: n/a
 
      07-02-2003
(Jorge) wrote in message news:<. com>...
> All,
>
> I've got a process that creates some children and want to be alerted
> when they die. To do this, the SIGCHLD signal is registered in the
> process using sigaction to jump to a subprogram as soon as it's
> received.
>
> The problem comes when many children exit at the same time and their
> father seems to miss some of them. This happens quite often, but not
> always.
>


I noticed this problem on linux using the sigqueue function. I was
writing
in C. On Solaris, I never missed signals.

I don't think you can consider signals reliable. Some of them
will be dropped. I went looking through the linux source a while ago
trying to figure out why. It looked like the kernel would skip
delivering a signal if the task struct for the process already had
that same signal marked for delivery on the process. So, if 2 signals
were delivered before the first was handled, the process would only
know
1 signal was delivered. Perhpas HPUX is similar.

Here is a thread where I was writing about this:
(I don't think I explained it too well then and I still dont know if I
was
right)
http://cboard.cprogramming.com/showt...sigqueue+linux

You might want to do periodic checks of the pids you know you started,
using the non-blocking version of waitpid.


> Why are the signals being missed? I'm pretty sure it's something with
> the flags on sigaction, but I've tryed several options and it's always
> the same.
>


If you really want to explore this, you should check with people in
comp.unix.programmer, etc....

> I appreciate your suggestions. Thanks in advance.
>
> PS: Perl 2.5.1, hpux 11.00


You are joking about perl 2.5.1 right? How old would that be?

<snip code>
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Aside from delta cycles and/or resolution functions, how can the effective value of a signal differ from a driving signal of its? Colin Paul Gloster VHDL 0 01-11-2007 01:31 PM
threading.Thread vs. signal.signal Jack Orenstein Python 0 09-17-2005 11:24 PM
Async-signal safe functions in signal handlers (unix) Michael Pronath Python 1 01-03-2005 01:10 PM
How do I: Main thread spawn child threads, which child processes...control those child processes? Jeff Rodriguez C Programming 23 12-09-2003 11:06 PM
Child signal behaviour on HPUX Jorge Perl 1 07-02-2003 07:19 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57