Created
May 29, 2016 19:57
-
-
Save greydot/8fe49b2c75dab8c35914ac008fb6828d to your computer and use it in GitHub Desktop.
Segfaults somewhere between 500 and 1000 iterations.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Monad (when) | |
import System.Exit (exitSuccess) | |
import System.Posix.Process (forkProcess) | |
fork_ :: Integer -> IO () | |
fork_ n | n > 0 = do pid <- forkProcess (fork_ $ n - 1) | |
when (pid /= 0) exitSuccess | |
| otherwise = putStrLn "I'm done!" | |
main :: IO () | |
main = fork_ 1000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment