in reply to Re^2: Cannot catch ALRM signal for timeout
in thread Cannot catch ALRM signal for timeout
but it still does not work :( Thank you for your hint, thosub process_scheme{ my ($output_file) = @_; open (OUTPUT_FILE, ">", $output_file) || die "cannot open lo +g file"; my $scheme_pid = open (WORKER, "worker_program < $input |") || die "cannot pipe worker"; my $str; while (1) { eval{ local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n r +equired alarm 1; if (eof(WORKER)){ close WORKER; close OUTPUT; return 1; } $str = <WORKER>; alarm 0; # if this line is removed, the signal is ca +ught, but outside of eval, so it halts the script }; if ($@) { close OUTPUT_FILE; close WORKER; return 0; } # process the line # some code ... # print the line to log print OUTPUT_FILE $str; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Cannot catch ALRM signal for timeout
by ikegami (Patriarch) on Dec 08, 2009 at 21:24 UTC | |
by Magice (Novice) on Dec 08, 2009 at 22:28 UTC | |
by almut (Canon) on Dec 08, 2009 at 23:35 UTC | |
by ikegami (Patriarch) on Dec 08, 2009 at 22:45 UTC |