-# timeout handler
-sub set_alarm {
- my $time = shift;
- my $message = shift || "";
-
- $time = 100 if !defined $time;
-
- $SIG{ALRM} = sub {
-
- warn "Time out alarm $time\n";
-
- # sends a hang-up signal to all processes in the current process group
- # and kill running java processes
- local $SIG{HUP} = "IGNORE";
- kill 1, -$$;
-
- local $SIG{TERM} = "IGNORE";
- kill 15, -$$;
- kill 15, -$$;
-
- warn "Send a hang-up to all childs.\n";
-
- #exit 1;
- };
-
- warn "set alarm time to: $time seconds $message\n" if $debug >= 1;
- alarm($time);
-}
-