Why do I have to kill?
David.Byng at bbc.co.uk
Tue Oct 16 11:10:16 BST 2007
It's probably the bcp command that's hanging the child, you could try
replacing system() with open2()
http://search.cpan.org/~nwclark/perl-5.8.8/lib/IPC/Open2.pm then you can
waitpid() on the bcp process.
my $pid = fork();
print "I'm the parent [$$] child [$pid]\n";
waitpid $pid, 0;
elsif(not defined $pid)
die "Can't fork()";
print "I'm the child [$$] parent[".getppid()."]\n";
my $bcp_pid = open2($rdr, $wrt, 'bcp rest of command');
waitpid $bcp_pid, 0;
From: london.pm-bounces at london.pm.org
[mailto:london.pm-bounces at london.pm.org] On Behalf Of Chris Jack
Sent: 16 October 2007 10:37
To: london.pm at london.pm.org
Subject: RE: Why do I have to kill?
>On Mon, 15 Oct 2007 16:19:24 +0100, "David Byng" David.Byng at bbc.co.uk
> waitpid() in parent for child to exit
Maybe I was a little too terse with the code I posted. The parent does a
waitpid on the child process id. The child process drops down to the
exit(0), but the child process doesn't die and the parent hangs around
forever. I need to do a:
kill 15, $$;
on the child to get it to die - which I can do but it's ugly, but I
guess I'm obliged to in the absence of any external inspiration. When I
do the kill in the child, the waitpid returns in the parent and all
I don't know how to use the perl debugger to see what's happening in the
child - and there are no obvious END blocks that might be doing anything
and there is way too much other code to start putting debug statements
into - even if I did believe they were likely to help.
The next generation of MSN Hotmail has arrived - Windows Live Hotmail
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