473,782 Members | 2,525 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Child signal behaviour on HPUX

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::SigActio n->new( 'my_handler', $sigset,
SA_NODEFER);
my $oldaction = POSIX::SigActio n->new;
my $return;

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

sigaction(SIGCH LD, $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
$
Jul 19 '05 #1
1 4134
jo****@yahoo.es (Jorge) wrote in message news:<f5******* *************** ****@posting.go ogle.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.progr ammer, 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>
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3046
by: Markus Franz | last post by:
Hi. I created a little script: for currenturl in sys.argv: pid = os.fork() if pid == 0: signal.alarm(10) do_something() # placeholder for the download and print routine
6
7052
by: Bob Swerdlow | last post by:
My application starts up a number of processes for various purposes using: self.popen = popen2.Popen3("/usr/local/bin/python -O "myscript.py") and then shuts them down when appropriate with os.kill(self.popen.pid, signal.SIGTERM) Everything works fine on MacOSX. However, I'm doing a port to Solaris (so I can run it on my web site) and find that the child processes are not stopping! Solaris is creating TWO new processes: one for the SHELL...
4
2018
by: Eric Boutin | last post by:
Hi ! currently reading C docs, I think I'm reading docs about the stdc lib, but I'm not shure.. it talks about signals, does *all* OS implement the signal function, and use it well ? I mean.. I know Unixes do it, but what about windows ? does it implements all SIG* signal promptly ? Thanks ! -Eric Boutin
11
2974
by: Jackie | last post by:
Hi everyone, I'd like to know when and how signals are used (e.g. SIGFPE, SIGABRT, SIGTERM, SIGSEGV, SIGINT)? Thank you so much.
2
2847
by: gnutuxy | last post by:
Hi, I am newbie in the Unix system programming and in learning phase. I usually read the libc manual and then try to implement small programs to test/check the learnt thing. I read the libc manual for signals and tried the program to check whether child inherits the signal handler intalled by parent befor fork.
18
3920
by: Sven | last post by:
Hi, I found a strange behaviour when using the time() function from time.h. Sometimes when it is called, it does not show the correct time in seconds, but an initial value. This time seem to be the time when the program was started the first time. My platform is a DEC machine with Tru64 onboard. A possible explanation could be, that the time() function is called
10
4035
by: subramanian | last post by:
Consider the following code: segment violation is deliberately generated to catch the SIGSEGV signal. The handler for this signal, namely SIGSEGV_handler, is called. However after the handler is finished, control does not return to the printf statement in main() which is present after the strcpy statement. Instead Segmentation violation error message is printed in Redhat Linux and the program is aborted. In VC++, the SIGSEGV_handler is...
3
2429
by: bp4444 | last post by:
On a HPUX, a CPP program. In main() defined a variable as int x = 900, called fork(), changed value of x as 89 in child process. Printed the address of x and value of x in child process and also in the parent process after wait(0). Doubt -------- Both in child and parent process, the address of x (&x) was same. Since the address of x is same, the value shows different in parent and child. Could you please reply. I got confused. ...
3
2283
by: joelq1981 | last post by:
Dear friends, I want to extend the interrupt handler of a program, my code is: ... if ($pid = fork) { local $SIG{INT} = sub { print "Please select:\n"; $choice = <STDIN>;
0
9641
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10146
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10080
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2875
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.