On 2/27/06, Arijit Das <[EMAIL PROTECTED]> wrote:

> So, I was just wondering if there is any other method of async process
> notification that I can use for this scenario apart from Signals? Basically,
> my requirement is, I have a script which should keep on doing its job but
> after 300 secs of elapsed time of its execution, it should invoke/execute a
> routine and once finished executing that routine, return back to what it was
> doing before the routine execution (exactly like how an interrupt is handled
> at a higher level). I tried doing this with alarm 300; but got into process
> hanging issues sometimes.

depending on what the sig handler is supposed to do, it might make more sense
to launch a thread before the waiting -- launch a process -- instead
of debugging
the alarm states.

$SIG{CHLD} = 'IGNORE';
$time = time();
$pid = fork;
$pid == 0 and do {
     sleep 300;
     do_that_voodoo_that_you_do_so_well();
     exit();
};
$pid < 0 and die "FORK PROBLEM: $!";
do some blocking thing that might take more than five minutes
(time() - $time) < 301 and kill 15,$pid;

of course that approach completely ignores cross-thread data
synchronization issues

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to