forkProcess fails with +RTS -N
- Dominant language
- Haskell
- Stars
- 124
- Forks
- 99
- PR merge metrics
- No merged PRs in 30d
Description
I have a program in which I use `forkProcess`. When it is run with `-threaded +RTS -N1`, it works fine, but when I use `-threaded +RTS -N2` I get this error:
```
failed to create OS thread: Resource temporarily unavailable
```
I haven't been able to reproduce this issue in a small test case, only within the larger program. To provide some context though, it' called only from the following function:
``` haskell
pOpen :: FilePath -> [String] -> (Handle -> IO a) -> IO a
pOpen fp args func = do
pipepair <- createPipe
pid <- do
p <- Control.Exception.try (forkProcess $ childstuff pipepair)
case p of
Right x -> return x
Left (e :: Control.Exception.IOException) -> fail ("Error in fork: " ++ show e)
retval <- callfunc pipepair
let rv = seq retval retval
void $ getProcessStatus True False pid
return rv
where
callfunc pipepair = do
closeFd (fst pipepair)
h <- fdToHandle (snd pipepair)
x <- func h
hClose h
return $! x
childstuff pipepair = do
void $ dupTo (fst pipepair) stdInput
closeFd $ fst pipepair
closeFd $ snd pipepair
executeFile fp True args Nothing
```
GHC Version: 7.10.3
unix version: 2.7.1.0
OS: Ubuntu 16.04
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at the pOpen entry point and its forkProcess call, then reproduce the larger program with GHC 7.10.3, unix 2.7.1.0, and +RTS -N1 versus -N2. Investigate the reported OS-thread creation failure and document a reproducible cause with a verified fix or limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100