h&FE75      !"#$%&'()*+,-./01234!(c) 2020 Composewell Technologies Apache-2.0streamly@composewell.com experimentalGHC Safe-Inferred5#streamly-process1An exception that is raised when a process fails.streamly-processThe exit code of the process.5streamly-process6 makes the new process inherit the terminal session from the parent process. This is the default.7 makes the new process start with a new session without a controlling terminal. On POSIX, setsid is used to create a new process group and session, the pid of the new process is the session id and process group id as well. On Windows DETACHED_PROCESS flag is used to detach the process from inherited console session.8 creates a new terminal and attaches the process to the new terminal on Windows, using the CREATE_NEW_CONSOLE flag. On POSIX this does nothing.For Windows see *  https://learn.microsoft.com/en-us/windows/win32/procthread/process-creation-flags *  https://learn.microsoft.com/en-us/windows/console/creation-of-a-console .For POSIX see, setsid man page.6streamly-processInherit the parent session7streamly-process'Detach process from the current session8streamly-process%Windows only, CREATE_NEW_CONSOLE flagstreamly-process6Process configuration used for creating a new process.By default the process config is setup to inherit the following attributes from the parent process:Current working directoryEnvironment variablesOpen file descriptors Process groupTerminal session On POSIX:Process uid and gidSignal handlersOn Windows by default the parent process waits for the entire child process tree to finish.9streamly-processCreate a default process configuration from an executable file path and an argument list.streamly-process;Set the current working directory of the new process. When :>, the working directory is inherited from the parent process. Default is :% - inherited from the parent process.streamly-process8Set the environment variables for the new process. When :8, the environment is inherited from the parent process. Default is :% - inherited from the parent process.streamly-processClose all open file descriptors inherited from the parent process. Note, this does not apply to stdio descriptors - the behavior of those is determined by other configuration settings. Default is ;.Note: if the number of open descriptors is large, it may take a while closing them.streamly-processIf < the new process starts a new process group, becomes a process group leader, its pid becoming the process group id.See the POSIX setpgid man page. Default is ;8, the new process belongs to the parent's process group.streamly-process9Define the terminal session behavior for the new process. Default is 6.streamly-processUse the POSIX setuid call to set the user id of the new process before executing the command. The parent process must have sufficient privileges to set the user id.POSIX only. See the POSIX setuid man page. Default is : - inherit from the parent. streamly-processUse the POSIX setgid call to set the group id of the new process before executing the command. The parent process must have sufficient privileges to set the group id.POSIX only. See the POSIX setgid man page. Default is : - inherit from the parent. streamly-process When this is <5, the parent process ignores user interrupt signals SIGINT and SIGQUIT delivered to it until the child process exits. If multiple child processes are started then the default handling in the parent is restored only after the last one exits.When a user presses CTRL-C or CTRL- on the terminal, a SIGINT or SIGQUIT is sent to all the foreground processes in the terminal session, this includes both the child and the parent. By default, on receiving these signals, the parent process would cleanup and exit, to avoid that and let the child handle these signals we can choose to ignore these signals in the parent until the child exits.POSIX only. Default is ;. streamly-processOn Windows, the parent waits for the entire tree of process i.e. including processes that are spawned by the child process. Default is <.=streamly-processOn normal cleanup we do not need to close the pipe handles as they are already guaranteed to be closed (we can assert that) by the time we reach here. We should not kill the process, rather wait for it to terminate normally.>streamly-processOn an exception or if the process is getting garbage collected we need to close the pipe handles, and send a SIGTERM to the process to clean it up. Since we are using SIGTERM to kill the process, it may block forever. We can possibly use a timer and send a SIGKILL after the timeout if the process is still hanging around.?streamly-processCreates a system process from an executable path and arguments. For the default attributes used to create the process see 9.streamly-processpipeBytesEither path args input runs the executable at path using args as arguments and input stream as its standard input. The error stream of the executable is presented as @6 values in the resulting stream and output stream as A values.Raises  exception in case of failure.>For example, the following is equivalent to the shell command ,echo "hello world" | tr [:lower:] [:upper:]::{4 pipeBytesEither "echo" ["hello world"] Stream.nil & Stream.catRights2 & pipeBytesEither "tr" ["[:lower:]", "[:upper:]"] & Stream.catRights & Stream.fold Stdio.write :} HELLO WORLDstreamly-processpipeChunks file args input runs the executable file& specified by its name or path using args as arguments and input stream as its standard input. Returns the standard output of the executable as a stream.If only the name of an executable file is specified instead of its path then the file name is searched in the directories specified by the PATH environment variable.If the input stream throws an exception or if the output stream is garbage collected before it could finish then the process is terminated with SIGTERM.;If the process terminates with a non-zero exit code then a  exception is raised.6The following code is equivalent to the shell command $echo "hello world" | tr [a-z] [A-Z]::{* Process.toChunks "echo" ["hello world"]- & Process.pipeChunks "tr" ["[a-z]", "[A-Z]"] & Stream.fold Stdio.writeChunks :} HELLO WORLD pre-releasestreamly-processLike  except that it works on a stream of bytes instead of a stream of chunks.We can write the example in  as follows.:{) Process.toBytes "echo" ["hello world"], & Process.pipeBytes "tr" ["[a-z]", "[A-Z]"] & Stream.fold Stdio.write :} HELLO WORLD pre-releasestreamly-processLike  except that it works on a stream of chars instead of a stream of chunks.:{) Process.toChars "echo" ["hello world"], & Process.pipeChars "tr" ["[a-z]", "[A-Z]"] & Stdio.putChars :} HELLO WORLDWe can seamlessly replace the tr process with the Haskell toUpper function::{) Process.toChars "echo" ["hello world"] & fmap toUpper & Stdio.putChars :} HELLO WORLD pre-releasestreamly-processtoBytesEither path args runs the executable at path using args' as arguments and returns a stream of B bytes. The @ values are from stderr and the A values are from stdout of the executable.Raises  exception in case of failure.The following example uses echo to write hello to stdout and world to stderr, then uses folds from Streamly.Console.Stdio to write them back to stdout and stderr respectively::{ Process.toBytesEither "/bin/bash" ["-c", "echo 'hello'; echo 'world' 1>&2"]9& Stream.fold (Fold.partition Stdio.writeErr Stdio.write):}worldhello((),())streamly-process6The following code is equivalent to the shell command echo "hello world"::{) Process.toBytes "echo" ["hello world"] & Stream.fold Stdio.write :} hello worldstreamly-processLike  but generates a stream of  Array Word8 instead of a stream of Word8.:{ toChunksEither "bash" ["-c", "echo 'hello'; echo 'world' 1>&2"]& Stream.fold (Fold.partition Stdio.writeErrChunks Stdio.writeChunks):}worldhello((),())&toChunksEither = toChunksEitherWith idPrefer 'toChunksEither over 'toBytesEither when performance matters. Pre-releasestreamly-process6The following code is equivalent to the shell command echo "hello world"::{* Process.toChunks "echo" ["hello world"] & Stream.fold Stdio.writeChunks :} hello worldtoChunks = toChunksWith idstreamly-process:toChars path args = toBytes path args & Unicode.decodeUtf8streamly-process9toLines path args f = toChars path args & Unicode.lines f streamly-processtoString path args = toChars path args & Stream.fold Fold.toList!streamly-process9toStdout path args = toChunks path args & Stdio.putChunks"streamly-process>toNull path args = toChunks path args & Stream.fold Fold.drain$streamly-processInherits stdin, stdout, and stderr from the parent, so that the user can interact with the process, user interrupts are handled by the child process, the parent waits for the child process to exit.This is same as the common system= function found in other libraries used to execute commands.On Windows you can pass setSession NewConsole to create a new console.%streamly-processCloses stdin, stdout and stderr, creates a new session, detached from the terminal, the parent does not wait for the process to finish.?streamly-processProcess attribute modifierstreamly-processExecutable pathstreamly-process Argumentsstreamly-process;(Input Handle, Output Handle, Error Handle, Process Handle)Cstreamly-processPath to Executablestreamly-process Argumentsstreamly-process Output streamstreamly-processConfig modifierstreamly-processExecutable name or pathstreamly-process Argumentsstreamly-process Input streamstreamly-process Output streamstreamly-processExecutable name or pathstreamly-process Argumentsstreamly-process Input streamstreamly-process Output streamstreamly-processExecutable name or pathstreamly-process Argumentsstreamly-process Input Streamstreamly-process Output Streamstreamly-processConfig modifierstreamly-processExecutable name or pathstreamly-process Argumentsstreamly-process Input streamstreamly-process Output streamstreamly-processExecutable name or pathstreamly-process Argumentsstreamly-process Input streamstreamly-process Output streamstreamly-processExecutable name or pathstreamly-process Argumentsstreamly-process Input streamstreamly-process Output streamstreamly-processExecutable name or pathstreamly-process Argumentsstreamly-process Input Streamstreamly-process Output Streamstreamly-processExecutable name or pathstreamly-process Argumentsstreamly-process Input Streamstreamly-process Output Streamstreamly-processExecutable name or pathstreamly-process Argumentsstreamly-process Input Streamstreamly-process Output Streamstreamly-processConfig modifierstreamly-processExecutable name or pathstreamly-process Argumentsstreamly-process Output streamstreamly-processConfig modifierstreamly-processExecutable name or pathstreamly-process Argumentsstreamly-process Output streamstreamly-processExecutable name or pathstreamly-process Argumentsstreamly-process Output Streamstreamly-processExecutable name or pathstreamly-process Argumentsstreamly-process Output Streamstreamly-processExecutable name or pathstreamly-process Argumentsstreamly-process Output Streamstreamly-processExecutable name or pathstreamly-process Argumentsstreamly-process Output Streamstreamly-processExecutable name or pathstreamly-process Argumentsstreamly-process Output Streamstreamly-processExecutable name or pathstreamly-process Argumentsstreamly-process Output Stream streamly-processExecutable name or pathstreamly-process Arguments!streamly-processExecutable name or pathstreamly-process Arguments"streamly-processExecutable name or pathstreamly-process Arguments#streamly-processWait for process to finish?streamly-processclose (stdin, stdout, stderr)streamly-processExecutable name or pathstreamly-process Arguments$streamly-processExecutable name or pathstreamly-process Arguments%streamly-processExecutable name or pathstreamly-process Arguments&  !"#$%&    !"#$%!(c) 2022 Composewell Technologies Apache-2.0streamly@composewell.com experimentalGHC Safe-InferredC (streamly-process)A modifier for stream generation APIs in Streamly.System.Process+ to generate streams from command strings. For example:8streamWith Process.toBytes "echo hello" & Stdio.putByteshello:streamWith Process.toChunks "echo hello" & Stdio.putChunkshelloInternal)streamly-process'A modifier for process running APIs in Streamly.System.Process to run command strings. For example:%runWith Process.toString "echo hello" "hello\n"%runWith Process.toStdout "echo hello"helloInternal*streamly-process&A modifier for process piping APIs in Streamly.System.Process> to pipe data through processes specified by command strings. For example::{ toChunks "echo hello"/ & pipeWith Process.pipeChunks "tr [a-z] [A-Z]" & Stdio.putChunks :}HELLOInternal+streamly-processpipeChunks command input2 runs the executable with arguments specified by command and supplying input stream as its standard input. Returns the standard output of the executable as a stream of byte arrays.If only the name of an executable file is specified instead of its path then the file name is searched in the directories specified by the PATH environment variable.If the input stream throws an exception or if the output stream is garbage collected before it could finish then the process is terminated with SIGTERM.;If the process terminates with a non-zero exit code then a ProcessFailure exception is raised.6The following code is equivalent to the shell command $echo "hello world" | tr [a-z] [A-Z]::{ toChunks "echo hello world" & pipeChunks "tr [a-z] [A-Z]" & Stdio.putChunks :} HELLO WORLD Pre-release,streamly-processLike + except that it works on a stream of bytes instead of a stream of chunks.:{ toBytes "echo hello world" & pipeBytes "tr [a-z] [A-Z]" & Stdio.putBytes :} HELLO WORLD Pre-release-streamly-processLike + except that it works on a stream of chars instead of a stream of chunks.:{ toChars "echo hello world" & pipeChars "tr [a-z] [A-Z]" & Stdio.putChars :} HELLO WORLD Pre-release.streamly-process$toBytes = streamWith Process.toBytes+toBytes "echo hello world" & Stdio.putBytes hello world-toBytes "echo hello\\ world" & Stdio.putBytes hello world-toBytes "echo 'hello world'" & Stdio.putBytes hello world/toBytes "echo \"hello world\"" & Stdio.putBytes hello world Pre-release/streamly-process&toChunks = streamWith Process.toChunks-toChunks "echo hello world" & Stdio.putChunks hello world Pre-release0streamly-process$toChars = streamWith Process.toChars+toChars "echo hello world" & Stdio.putChars hello world Pre-release1streamly-process*toLines f = streamWith (Process.toLines f)toLines Fold.toList "echo -e hello\\\\nworld" & Stream.fold Fold.toList["hello","world"] Pre-release2streamly-process#toString = runWith Process.toStringtoString "echo hello world""hello world\n" Pre-release3streamly-process#toStdout = runWith Process.toStdouttoStdout "echo hello world" hello world Pre-release4streamly-processtoNull = runWith Process.toNulltoNull "echo hello world" Pre-release1streamly-processCommandstreamly-process Output Stream2streamly-processCommand3streamly-processCommand4streamly-processCommand ()*+,-./01234 ./01234,-+)(*!(c) 2023 Composewell Technologies Apache-2.0streamly@composewell.com experimentalGHC Safe-InferredD +,-./01234 ./01234,-+!(c) 2020 Composewell Technologies Apache-2.0streamly@composewell.com experimentalGHC Safe-InferredE!        !"#$%&'()*+,-.!"#$%&/012345678978:;<=4>?4>@4>AB-streamly-process-0.3.0-KIqrzZ5AB0WBBHJ1qROY5g Streamly.Internal.System.Process Streamly.Internal.System.CommandStreamly.System.CommandStreamly.System.ProcessProcessFailureConfigsetCwdsetEnv closeFilesnewProcessGroup setSession setUserId setGroupIdparentIgnoresInterruptwaitForChildTree pipeStdErr inheritStdin inheritStdoutpipeChunksEitherWithpipeChunksEitherpipeBytesEitherpipeChunksWith pipeChunks processChunks pipeBytes processBytes pipeCharstoChunksEitherWith toChunksWith toBytesEithertoBytestoChunksEithertoChunkstoCharstoLinestoStringtoStdouttoNull standalone interactivedaemon$fExceptionProcessFailure$fShowProcessFailure streamWithrunWithpipeWithSessionInheritSession NewSession NewConsolemkConfigbase GHC.MaybeNothingghc-prim GHC.TypesFalseTrue cleanupNormalcleanupException createProc' Data.EitherLeftRightEitherpipeChunksWithAction