
On Jul 24, 2018, at 9:42 AM, Johannes Waldmann
wrote: Now I would like to time-out this after a while. I can use https://hackage.haskell.org/package/base-4.11.1.0/docs/System-Timeout.html and this works in simple cases -
but not in case the external command has spawned child processes. (cleanupProcess sends SIGTERM but only to the process at the top of the tree ?)
You could start a wrapper process that starts the real process, the wrapper process would kill the process group it spawned. wrapper command [args ...] would run command as a child in its own process group and propagates termination signals (SIGHUP, SIGINT, SIGTERM) to the child process. There are likely multiple such wrappers available. I don't have a particular one to recommend. -- Viktor.