how to terminate an external program after timeout?
Brandon S Allbery KF8NH
allbery at ece.cmu.edu
Fri Sep 10 12:04:28 EDT 2010
-----BEGIN PGP SIGNED MESSAGE-----
On 9/10/10 04:59 , Christian Maeder wrote:
> 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?
If metis exits, the backgrounded sleep will keep going, the kill will
silently fail, in effect that can be ignored. It would be possible to set
up something that nuked the background sleep but then getting the full exit
status of metis (if needed; i.e. signals) is complex.
(If your shell is too smart to let the background process deal with itself,
toss in a "disown %1" before exec-ing metis. Shells that do
interactive-style process management when not interactive are broken, though.)
brandon s. allbery [linux,solaris,freebsd,perl] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university KF8NH
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.10 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
-----END PGP SIGNATURE-----
More information about the Glasgow-haskell-users