aesiniath / unbeliever

Opinionated Haskell Interoperability
https://hackage.haskell.org/package/unbeliever
MIT License
33 stars 11 forks source link

Enable launching child processes #185

Closed istathar closed 1 year ago

istathar commented 1 year ago

A variant of readProcess (which gets the child's output) is callProcess, which just runs a child and waits for it to finish. This branch adds a wrapper around that function.

istathar commented 1 year ago

I'm trying to simulate the advertised behaviour that

If an asynchronous exception is thrown to the thread executing callProcess, the forked process will be terminated and callProcess will wait (block) until the process has been terminated.

but I haven't managed to see that actually happen yet. Like, it's blocking (something is?) but the child isn't terminating?

istathar commented 1 year ago

This has also cleaned up the behaviour of cancelThread a touch. So many corner cases.

istathar commented 1 year ago

The process library offers cleanupProcess, https://hackage.haskell.org/package/process-1.6.17.0/docs/System-Process.html#v:cleanupProcess. I don't know if there's any particular advantage to calling that; reading the code there they've covered off a few cases but I suspect what would be better is us directly sending SIGTERM and a bit later SIGKILL ourselves rather than relying on terminateProcess (which only sends SIGTERM).

(that can happen in another PR, potentially)