View Full Version : Perl + forking

11-30-2009, 07:49 PM
I have a perl script that forks a command from the parent process and then kills it a few seconds later. The problem I am running into is that sometimes the process isn't killed(the script tries to kill the wrong pid). For whatever reason I am having to increment the pid of my spawned process by +1 to get the correct number. Please see the code below...

my $pid = fork();
if (not defined $pid) {
warn "resources not available.\n";
elsif ($pid == 0) {
else {
kill 9, $pid;

Any help is much appreciated!

11-30-2009, 11:19 PM
if that fork(); is a function can we see it? maybe the value of pid is being created differently from how you think?


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum