Why do I have to kill?

David Byng David.Byng at bbc.co.uk
Mon Oct 15 16:19:24 BST 2007

waitpid() in parent for child to exit

-----Original Message-----
From: london.pm-bounces at london.pm.org
[mailto:london.pm-bounces at london.pm.org] On Behalf Of Chris Jack
Sent: 15 October 2007 15:54
To: london.pm at london.pm.org
Subject: Why do I have to kill?

I have a perl program running on Unix that does a fork, runs a process
in the child, and exits. If I just let it exit(0) - then the Unix
process doesn't die. If I do a kill 15, the child process does go away.
I've tried running the Perl debugger on it, but it stops when the parent
stops. This thing has a zillion libraries so it's hard to know what else
might be effecting it. If I run truss on the process it tells me:
lwp_sema_wait(0x000F5630)       (sleeping...)signotifywait()
(sleeping...)lwp_cond_wait(0xFF0DCD30, 0xFF0DCD18, 0x00000000)
Some relevant lines from the program are:
$pid = fork();if (not defined $pid) { print "resources not
available.\n";} elsif ($pid == 0) { print "IM THE CHILD: $$ " .
getppid() . "\n"; sleep(1); system('bcp - rest of cmd omitted, but it
works.'); print "CHILD finished\n"; # kill 15, $$; exit(0);}else {print
"child  pid is $pid\n";print "parent pid is $$\n";print "IM THE
I get the "CHILD finished" message, but if I need to uncomment the kill
to get the child process to die.
Any ideas anyone?
Celeb spotting - Play CelebMashup and win cool prizes

This e-mail (and any attachments) is confidential and may contain personal views which are not the views of the BBC unless specifically stated.
If you have received it in error, please delete it from your system.
Do not use, copy or disclose the information in any way nor act in reliance on it and notify the sender immediately.
Please note that the BBC monitors e-mails sent or received.
Further communication will signify your consent to this.

More information about the london.pm mailing list