E
elastic
I'm trying to implement a simple timer to work on win32 (98,2k,xp),
solaris and linux. where the last two are simple, the first seems to
be problematic.
the problem is that the kill command seems to always fail.
the pid is always negative and doesn't apear in the task manager.
this is the perl version I'm using :
This is perl, v5.6.1 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-2001, Larry Wall
Binary build 635 provided by ActiveState Corp.
http://www.ActiveState.com
Built 15:34:21 Feb 4 2003
this is the function :
sub system_with_timeout {
my ($rc);
my ($command) = @_;
$pid = fork ();
if (! (defined ($pid))) { #hosed
die "fork() error: $!\n";
} elsif ($pid == 0) { #child
$rc = system ($command);
} else { #parent (defined $pid)
for ($i = 0 ; $i < $g_APP_RUN_TIMEOUT_SEC ; $i++) {
sleep 1;
if (kill 0, $pid) {
kill 9, $pid;
return -1;
}
}
}
return $rc;
}
if anyone has any idea of what I'm doing wrong here, please help.
solaris and linux. where the last two are simple, the first seems to
be problematic.
the problem is that the kill command seems to always fail.
the pid is always negative and doesn't apear in the task manager.
this is the perl version I'm using :
This is perl, v5.6.1 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-2001, Larry Wall
Binary build 635 provided by ActiveState Corp.
http://www.ActiveState.com
Built 15:34:21 Feb 4 2003
this is the function :
sub system_with_timeout {
my ($rc);
my ($command) = @_;
$pid = fork ();
if (! (defined ($pid))) { #hosed
die "fork() error: $!\n";
} elsif ($pid == 0) { #child
$rc = system ($command);
} else { #parent (defined $pid)
for ($i = 0 ; $i < $g_APP_RUN_TIMEOUT_SEC ; $i++) {
sleep 1;
if (kill 0, $pid) {
kill 9, $pid;
return -1;
}
}
}
return $rc;
}
if anyone has any idea of what I'm doing wrong here, please help.