sub process_scheme{ my ($output_file) = @_; open (OUTPUT_FILE, ">", $output_file) || die "cannot open log file"; my $scheme_pid = open (SCHEME, "./t.pl | ") || die "cannot pipe scheme"; my $str = ""; MAIN: while (1) { eval{ local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required alarm 5;#$allow_time; if (eof(SCHEME)){ close OUTPUT_FILE; close SCHEME; last MAIN; } $str = ; alarm 0; }; if ($@) { close OUTPUT_FILE; kill $scheme_pid; close SCHEME; return -$current_player; } # process the line print OUTPUT_FILE $str; } return 1; } #### while(1){};