Skip to content

stack exec not propagating signals #527

@zimbatm

Description

@zimbatm

I would expect stack exec to only terminate if it's child process has died, and consequently forward it's INT/TERM signals to it.

When running end-to-end integration tests I execute a fresh set of haskell processes for each test to make sure their state is clean. On each test processes are started, checks are run and processes are stopped (or sometimes during the test to simulate failure). When using cabal sandbox I was executing the binary directly from within the dist/ folder.

While migrating the project to using stack I was expecting to replace the ./dist/<project>/<project> binary path with just stack exec <project>.

Steps to reproduce:

  1. stack exec -- sleep 10000 &
  2. pid=$!
  3. kill $pid
  4. sleep 10000 is still running (eg: ps aux | grep -v grep | grep sleep)

Expected:

I would expect stack exec to forward INT/TERM signals to the child process and only terminate when the child-process has exited.

Actual:

stack exec dies and leaves a zombie process around

Here is the stack ---version output:

$ stack --version
Version 0.1.2.0, Git revision 65246552936b7da4b64b38372feac903d96a8911

Here is the command I ran with --verbose:

$ stack --verbose exec sleep -- 10000
Version 0.1.2.0, Git revision 65246552936b7da4b64b38372feac903d96a8911
2015-07-06 15:44:51.51753: [debug] Checking for project config at: /Users/zimbatm/stack.yaml @(stack-0.1.2.0:Stack.Config src/Stack/Config.hs:496:9)
2015-07-06 15:44:51.517853: [debug] Checking for project config at: /Users/stack.yaml @(stack-0.1.2.0:Stack.Config src/Stack/Config.hs:496:9)
2015-07-06 15:44:51.518093: [debug] Checking for project config at: /stack.yaml @(stack-0.1.2.0:Stack.Config src/Stack/Config.hs:496:9)
2015-07-06 15:44:51.518239: [debug] No project config file found, using defaults. @(stack-0.1.2.0:Stack.Config src/Stack/Config.hs:523:13)
2015-07-06 15:44:51.520458: [info] Using resolver: lts-2.17 from global config file: /Users/zimbatm/.stack/global/stack.yaml @(stack-0.1.2.0:Stack.Config src/Stack/Config.hs:302:32)
2015-07-06 15:44:51.530588: [debug] Run process: ghc --info @(stack-0.1.2.0:System.Process.Read src/System/Process/Read.hs:254:3)
2015-07-06 15:44:51.602371: [debug] Run process: ghc --numeric-version @(stack-0.1.2.0:System.Process.Read src/System/Process/Read.hs:254:3)
2015-07-06 15:44:51.634031: [debug] Run process: ghc-pkg --no-user-package-db field --simple-output Cabal id @(stack-0.1.2.0:System.Process.Read src/System/Process/Read.hs:254:3)
2015-07-06 15:44:51.662563: [debug] Run process: ghc-pkg --no-user-package-db list --global @(stack-0.1.2.0:System.Process.Read src/System/Process/Read.hs:254:3)
2015-07-06 15:44:51.693961: [debug] Run process: /bin/sleep 10000 @(stack-0.1.2.0:Stack.Exec src/Stack/Exec.hs:52:5)
### TERM signal is sent here ###
[1]    80002 terminated  stack --verbose exec sleep -- 10000

Workaround:

I'm not sure of the full implications but for now I first resolve the executable path using stack exec which -- <executable> and then invoke the executable directly.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions