in reply to Getting around Win32 limitations
alarm_pg.pm: package pg_alarm; use strict; sub new { shift; my $seconds = shift; my $self = {}; $self->{CHILD_PID} = fork(); if ($self->{CHILD_PID} == 0) { sleep($seconds);
} bless $self; return $self; } sub alarmed { my $self = shift; my $result = 0; if (defined($self->{CHILD_PID})) { my $ret = waitpid($self->{CHILD_PID}, 1); if ($ret == -1) { $result = 1; } } return $result; }
|
---|