Perl killed after child spawn

E

earthwormgaz

Hi,

I'm using Perl to run some tests over night. The tests are written in C
++ and they spawn their own child processes.

I'm finding that if my C++ child process bombs out with signal ABRT
(this is on Solaris btw, with Perl v5.8.4), then Perl dies. The script
run just says "Killed" and that's all I get out of it.

I tried running through the Perl debugger, but that just gets killed
too. Is there some way to make the script more resiliant to this sort
of thing? Or is it maybe a Perl bug in this version?

Any help would be great, I'm only vaguely familiar with Perl.

Thanks!

Gaz
 
R

RedGrittyBrick

earthwormgaz said:
Hi,

I'm using Perl to run some tests over night. The tests are written in C
++ and they spawn their own child processes.

I'm finding that if my C++ child process bombs out with signal ABRT
(this is on Solaris btw, with Perl v5.8.4), then Perl dies. The script
run just says "Killed" and that's all I get out of it.

I tried running through the Perl debugger, but that just gets killed
too. Is there some way to make the script more resiliant to this sort
of thing? Or is it maybe a Perl bug in this version?

Any help would be great, I'm only vaguely familiar with Perl.

I'd try
perldoc -q trap
 
K

Krishna Chaitanya

Can you give us a little more info through pseudo-code or still
better, real code?
 
E

earthwormgaz

Can you give us a little more info through pseudo-code or still
better, real code?

The Perl uses backticks to launch the C++ program, and stores the
program output in a variable.

I've got this lot at the top trying to catch if anything nasty
happens, but I never see the goat message.

$SIG{ABRT} = sub { msg("goat!!!!!!"); };
$SIG{TERM} = sub { msg("goat!!!!!!"); };
$SIG{SEGV} = sub { msg("goat!!!!!!"); };
$SIG{FPE} = sub { msg("goat!!!!!!"); };
$SIG{ILL} = sub { msg("goat!!!!!!"); };
$SIG{INT} = sub { msg("goat!!!!!!"); };
 
K

Krishna Chaitanya

Well, I don't know about the msg function but you can add the
backticks code inside an eval block, and then check on $@? Just
thinking aloud. Also it won't hurt to have an END block print out
anything you want.
 
T

Tad J McClellan

(this is on Solaris btw, with Perl v5.8.4), then Perl dies. The script
run just says "Killed" and that's all I get out of it.
^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^

That is a symptom of the "Linux OOM killer", but I thought
Solaris didn't use memory overcommitt...

http://developers.sun.com/solaris/articles/subprocess/subprocess.html

I tried running through the Perl debugger, but that just gets killed
too. Is there some way to make the script more resiliant to this sort
of thing? Or is it maybe a Perl bug in this version?


I'd look into the possibility of running out of memory anyway.
 
E

earthwormgaz

Well, I don't know about the msg function but you can add the
backticks code inside an eval block, and then check on $@? Just
thinking aloud. Also it won't hurt to have an END block print out
anything you want.

I looked at an eval block, and wrapped my backtick call in one ...

eval {
$result = `$testLocalBin` or die "oh bugger\n";
}; warn $@ if $@;

It looks like the above now. My Perl script still runs thusly ...

bash-3.00$ ./runTests.pl
Entering directory /tests/unittests
Killed
 
R

RedGrittyBrick

Krishna said:
Can you give us a little more info through pseudo-code or still
better, real code?

Here's a fish ...

$ cat forkabort.pl
#!/usr/bin/perl
use strict;
use warnings;

print "Parent $$\n";
my $parent_pid = $$;

sub catch_abort {
my $signame=shift;
print "$$ ignoring signal $signame\n";
}
$SIG{ABRT} = \&catch_abort;

my $child_pid;
if (!defined($child_pid = fork())) {
die "cannot fork: $!";
} elsif ($child_pid) {
# -------------------- PARENT process ----------------
print "Parent $$ will now wait for child $child_pid\n";
waitpid($child_pid, 0);
print "Parent $$ finished waiting for child\n";
} else {
# --------------------- CHILD process ------------------
print "Child $$ busy for 2s ... \n";
sleep 2;
print "Child $$ sending parent $parent_pid an ABORT signal ... \n";
kill 6, $parent_pid;
print "Child $$ busy 2s ... \n";
sleep 2;
print "Child $$ done.\n";
}

Read the docs!
 
P

Peter J. Holzer

I looked at an eval block, and wrapped my backtick call in one ...

eval {
$result = `$testLocalBin` or die "oh bugger\n";
}; warn $@ if $@;

It looks like the above now. My Perl script still runs thusly ...

bash-3.00$ ./runTests.pl
Entering directory /tests/unittests
Killed

You cannot catch a KILL signal. You will have to find out where the
signal comes from. I would be very surprised if a SIGABRT to one process
would directly cause a SIGKILL on another process. Most likely there is
something in the test framework which causes this (catching SIGABRT and
then sending SIGKILL to all processes in the process group?). DTrace and
truss are probably good tools to find out what is happening.

hp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top