in reply to timeout process problems
I'm not sure why you are getting 56 timeouts. Just for kicks, try doing a 'ps' during this and see if you are accumulating child processes (and eventually reach your limit).
Since then I've tried other solutions, but can't say I've ever come across what I thought was especially clean. I don't like using signals much since they are unsafe and I'm paranoid (as my previous post details). I tend to fork/exec the process off, send the output to a temp file, and then (lamely) do a nonblocking waitpid call in a polling loop where I sleep 1 second each time through to check on it. You can replace the waitpid loop with something (untested) like ...
... but why bother? (The polling solution does keep your process in memory during the wait, and uses a small amount of CPU time.) FWIW, you can also do the same kind of thing without a temp file by redirecting output to a pipe to the parent (if you are careful).eval { local $SIG{ALRM} = sub { die 'timedout' }; alarm $time_to_wait; waitpid($pid, 0); $exit_code = $?; alarm(0); } if ($@) { $exit_code = ($@ =~ /timedout/)? 100 : 200; }
bluto
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: timeout process problems
by shrubbery (Acolyte) on Nov 07, 2001 at 20:18 UTC | |
by shrubbery (Acolyte) on Nov 08, 2001 at 00:42 UTC | |
by bluto (Curate) on Nov 08, 2001 at 01:50 UTC |