-
Notifications
You must be signed in to change notification settings - Fork 714
Closed
Description
Describe the bug
When cabal run
receives SIGTERM
, it exits, but leaves its children running.
I'm not entirely sure whether this is buggy behaviour, but I was surprised by this,
in the context of running a Haskell tool via cabal run
and withProcessTerm
.
If I run cabal run target
from the shell, and run
kill <cabal-run-pid>
, I would have expected both cabal
and target
to stop. Instead, cabal
exits but target
keeps running.
Note that when run interactively, Ctrl-C
sends SIGINT
to the whole
process group, which is how cabal run
interrupts nicely on Ctrl-C
.
To Reproduce
$ cat x.hs
{- cabal:
build-depends: base
-}
module Main where
import Control.Concurrent (threadDelay)
import Control.Exception
import Control.Monad (when)
main = loop `catch` logInterrupt
where
loop = do
putStrLn "yo"
threadDelay 1000000
loop
logInterrupt e = do
when (e == UserInterrupt) $ putStrLn "ouch"
throwIO e
Then call cabal run x.hs
, in a different terminal:
$ ps | grep cabal
77565 ttys002 0:04.09 cabal run x.hs
77726 ttys002 0:00.01 /s/cabal/dist-newstyle/build/x86_64-osx/ghc-8.10.7/fake-package-0/x/script/build/script/script
$ kill 77565
Then the child keeps running although cabal
exits:
yo
yo
yo
yo
Terminated: 15
$ yo
yo
yo
Expected behavior
I'd like the child process to be killed, too.
System information
- Operating system: macos
- cabal-install version 3.4.0.0, compiled using version 3.4.0.0 of the Cabal library
- ghc 8.10.7
jberryman, soupi and chris-martin