@@ -16,10 +16,13 @@ data PID : Type where
1616 MkPID : (pid : Ptr) -> PID
1717
1818||| Spawn a process in a new thread, returning the process ID
19+||| Returns `Nothing` if there are not enough resources to create the new thread
1920export
20−spawn : (process : IO ()) -> IO PID
21+spawn : (process : IO ()) -> IO (Maybe PID)
2122spawn proc = do pid <- fork proc
22− pure (MkPID pid)
23+ if !(nullPtr pid)
24+ then pure Nothing
25+ else pure (Just (MkPID pid))
2326
2427||| Create a channel which connects this process to another process
2528export