haskell / haskell/process

Error when using `interruptProcessGroupOf` on Mac OS

Open
#71 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
91
Forks
91
PR merge metrics
No merged PRs in 30d

Description

Running the code below in Ubuntu I got

```
$ ./Test
The Glorious Glasgow Haskell Compilation System, version 8.0.1
Just ExitSuccess
```

but in Mac OS my student @jonaprieto got

```
$ ./Test
The Glorious Glasgow Haskell Compilation System, version 8.0.1
Test.hs: getProcessGroupIDOf: does not exist (No such process)
```

The error disappears if I replace `interruptProcessGroupOf` by `terminateProcess`.

``` haskell
$ cat Test.hs

module Main where

import Data.Maybe
import System.IO
import System.Process

foo :: IO (ProcessHandle, String)
foo = do
(_, oh, _, ph) <-
createProcess CreateProcess
{ cmdspec = RawCommand "ghc" ["-V"]
, cwd = Nothing
, env = Nothing
, std_in = Inherit
, std_out = CreatePipe
, std_err = Inherit
, close_fds = False
, create_group = True
, delegate_ctlc = False
, create_new_console = False
, detach_console = False
, new_session = False
, child_group = Nothing
, child_user = Nothing
}

o <- hGetContents $ fromMaybe (error "foo") oh
return (ph, o)

main :: IO ()
main = do
(ph, o) <- foo
putStr o

_ <- interruptProcessGroupOf ph
e <- getProcessExitCode ph
print e
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.