in reply to Re^2: Timer Question
in thread Timer Question

Depends on what is meant by "system call".

If it's system call, it's a call to the OS, like sysread, in which case alarm works exactly as required.

If it's "system() call", then things are different: system() forks a process, executes whatever's specified (different for single/multiple arguments), waits until the command is completed and then returns. It won't kill the spawned process, that's why it will run until the end.

Replies are listed 'Best First'.
Re^4: Timer Question
by ikegami (Patriarch) on Feb 17, 2006 at 02:58 UTC
    oh, yes, it does look like I misread the OP.
Re^4: Timer Question
by rudeb0y (Novice) on Feb 17, 2006 at 18:26 UTC
    it is a "system() call", how can I kill this after a certain amount of time...will alarm work per the other responses... Your help is greatly appreciated.
      On some systems, you can set an alarm on a child process like that:
      # instead of system("/foo/bar") do... my $pid = fork; if (defined $fork and not $fork) { alarm $timeout; exec "/foo/bar"; exit(1); # just in case exec fails. }