Processes

Forking and executing

forkProcess corresponds to the POSIX fork system call.
The IO action passed as an argument is executed in the child process; no other
threads will be copied to the child process.
On success, forkProcess returns the child's ProcessID to the parent process;
in case of an error, an exception is thrown.

forkProcess comes with a giant warning: since any other running
threads are not copied into the child process, it's easy to go wrong:
e.g. by accessing some shared resource that was held by another thread
in the parent. Another example is the I/O manager thread: since the
I/O manager isn't running in the child, attempting to do any
Handle-based I/O will deadlock.

executeFile cmd args env calls one of the
execv* family, depending on whether or not the current
PATH is to be searched for the command, and whether or not an
environment is provided to supersede the process's current
environment. The basename (leading directory names suppressed) of
the command is passed to execv* as arg[0];
the argument list passed to executeFile therefore
begins with arg[1].

getProcessStatus blk stopped pid calls waitpid, returning
Just tc, the ProcessStatus for process pid if it is
available, Nothing otherwise. If blk is False, then
WNOHANG is set in the options for waitpid, otherwise not.
If stopped is True, then WUNTRACED is set in the
options for waitpid, otherwise not.

getAnyProcessStatus blk stopped calls waitpid, returning
Just (pid, tc), the ProcessID and ProcessStatus for any
child process if one is available, Nothing otherwise. If
blk is False, then WNOHANG is set in the options for
waitpid, otherwise not. If stopped is True, then
WUNTRACED is set in the options for waitpid, otherwise not.

getGroupProcessStatus blk stopped pgid calls waitpid,
returning Just (pid, tc), the ProcessID and
ProcessStatus for any process in group pgid if one is
available, Nothing otherwise. If blk is False, then
WNOHANG is set in the options for waitpid, otherwise not.
If stopped is True, then WUNTRACED is set in the
options for waitpid, otherwise not.