unix-process-conduit- Run processes on Unix systems, with a conduit interface

Safe HaskellNone






:: ByteString


-> [ByteString]


-> Maybe [(ByteString, ByteString)]


-> Maybe ByteString

working directory

-> Maybe (Source IO ByteString)


-> Maybe (Sink ByteString IO ())


-> Maybe (Sink ByteString IO ())


-> IO ProcessHandle 

Fork a new process and execute the given command.

This is a wrapper around with fork() and exec*() syscalls, set up to work with conduit datatypes for standard input, output, and error. If Nothing is provided for any of those arguments, then the original file handles will remain open to the child process.

If you would like to simply discard data provided by the child process, provide sinkNull for stdout and/or stderr. To provide an empty input stream, use return ().

Since 0.1.0

killProcess :: ProcessHandle -> IO ()Source

Kill a process by sending it the KILL (9) signal.

Since 0.1.0

terminateProcess :: ProcessHandle -> IO ()

Attempts to terminate the specified process. This function should not be used under normal circumstances - no guarantees are given regarding how cleanly the process is terminated. To check whether the process has indeed terminated, use getProcessExitCode.

On Unix systems, terminateProcess sends the process the SIGTERM signal. On Windows systems, the Win32 TerminateProcess function is called, passing an exit code of 1.

Note: on Windows, if the process was a shell command created by createProcess with shell, or created by runCommand or runInteractiveCommand, then terminateProcess will only terminate the shell, not the command itself. On Unix systems, both processes are in a process group and will be terminated together.

waitForProcess :: ProcessHandle -> IO ExitCode

Waits for the specified process to terminate, and returns its exit code.

GHC Note: in order to call waitForProcess without blocking all the other threads in the system, you must compile the program with -threaded.