how to terminate an external program after timeout?

Christian Maeder Christian.Maeder at dfki.de
Fri Sep 10 04:59:45 EDT 2010


Brandon S Allbery KF8NH schrieb:
> On 9/9/10 05:35 , Christian Maeder wrote:
>>  System.Process.readProcessWithExitCode "metis" filename ""
> 
> If all else fails, there's:
> 
> sh -c '(sleep 120; kill -TERM $$ >/dev/null 2>&1) & exec metis'

Yes, I've considered something like this, too. It does not give metis a
chance to terminate earlier, does it?

I've found:

  perl -e 'alarm shift @ARGV; exec @ARGV' 120 metis filename

(metis is big already, so the additional perl call can be disregarded.)

(In case someone wants to rewrite System.Timeout.timeout I would also
suggest to return the output produced until the timeout occurs.)

Cheers Christian


More information about the Glasgow-haskell-users mailing list