h&VU$      !"#$%&'()*+,-./0123456789:;<=>?@A!(c) 2020 Composewell Technologies Apache-2.0streamly@composewell.com experimentalGHC Safe-Inferred=t)streamly-process1An exception that is raised when a process fails.streamly-processThe exit code of the process.streamly-process makes the new process inherit the terminal session from the parent process. This is the default. makes the new process start with a new session without a controlling terminal. On POSIX,  3https://man7.org/linux/man-pages/man2/setsid.2.htmlsetsid 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. 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,  3https://man7.org/linux/man-pages/man2/setsid.2.htmlsetsid man page.streamly-processInherit the parent sessionstreamly-process'Detach process from the current sessionstreamly-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.Bstreamly-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 C>, the working directory is inherited from the parent process. Default is C% - inherited from the parent process.streamly-process8Set the environment variables for the new process. When C8, the environment is inherited from the parent process. Default is C% - 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 D.Note: if the number of open descriptors is large, it may take a while closing them. streamly-processIf E the new process starts a new process group, becomes a process group leader, its pid becoming the process group id.See the POSIX  4https://man7.org/linux/man-pages/man2/setpgid.2.htmlsetpgid man page. Default is D8, the new process belongs to the parent's process group. streamly-process9Define the terminal session behavior for the new process. Default is . streamly-processUse the POSIX  3https://man7.org/linux/man-pages/man2/setuid.2.htmlsetuid 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  3https://man7.org/linux/man-pages/man2/setuid.2.htmlsetuid man page. Default is C - inherit from the parent. streamly-processUse the POSIX  3https://man7.org/linux/man-pages/man2/setgid.2.htmlsetgid 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  3https://man7.org/linux/man-pages/man2/setgid.2.htmlsetgid man page. Default is C - inherit from the parent.streamly-process When this is E5, 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 D.streamly-processOn Windows, the parent waits for the entire descendant tree of process i.e. including processes that are spawned by the child process. Default is E.Fstreamly-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.Gstreamly-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.Hstreamly-processCreates a system process from an executable path and arguments. For the default attributes used to create the process see B.streamly-processLike 9 but use the specified configuration to run the process.streamly-processLike  but also includes stderr as I stream in the J output.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 I6 values in the resulting stream and output stream as K 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-processLike 8 but use the specified configuration to run the process.streamly-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-processLike "9 but use the specified configuration to run the process.streamly-processLike #8 but use the specified configuration to run the process. streamly-processtoBytesEither path args runs the executable at path using args' as arguments and returns a stream of J bytes. The I values are from stderr and the K 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 world"streamly-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 " over   when performance matters. Pre-release#streamly-process6The following code is equivalent to the shell command echo "hello world"::{* Process.toChunks "echo" ["hello world"] & Stream.fold Stdio.writeChunks :} hello worldtoChunks = toChunksWith id$streamly-process:toChars path args = toBytes path args & Unicode.decodeUtf8%streamly-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-processLaunch a standalone process i.e. the process does not have a way to attach the IO streams with other processes. The IO streams stdin, stdout, stderr can either be inherited from the parent or closed.This API is more powerful than + and , and can be used to implement both of these. However, it should be used carefully e.g. if you inherit the IO streams and parent is not waiting for the child process to finish then both parent and child may use the IO streams resulting in garbled IO if both are reading/writing simultaneously.1If the parent chooses to wait for the process an L is returned otherwise a M is returned which can be used to terminate the process, send signals to it or wait for it to finish.*streamly-processLaunch a process interfacing with the user. User interrupts are sent to the launched process and ignored by the parent process. The launched process inherits stdin, stdout, and stderr from the parent, so that the user can interact with the process. The parent waits for the child process to exit, an L' is returned when the process finishes.This is the 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-processLaunch a daemon process. Closes stdin, stdout and stderr, creates a new session, detached from the terminal, the parent does not wait for the process to finish.The M returned can be used to terminate the daemon or send signals to it.Hstreamly-processProcess attribute modifierstreamly-processExecutable pathstreamly-process Argumentsstreamly-process;(Input Handle, Output Handle, Error Handle, Process Handle)Nstreamly-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 stream streamly-processExecutable name or pathstreamly-process Argumentsstreamly-process Output Stream!streamly-processExecutable name or pathstreamly-process Argumentsstreamly-process Output Stream"streamly-processExecutable name or pathstreamly-process Argumentsstreamly-process Output Stream#streamly-processExecutable name or pathstreamly-process Argumentsstreamly-process Output Stream$streamly-processExecutable name or pathstreamly-process Argumentsstreamly-process Output Stream%streamly-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,streamly-processExecutable name or pathstreamly-process Arguments-  !"#$%&'()*+,-   !#$%&'( "*,)+!(c) 2022 Composewell Technologies Apache-2.0streamly@composewell.com experimentalGHC Safe-InferredSt0streamly-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.putChunkshelloInternal1streamly-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"helloInternal2streamly-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 :}HELLOInternal3streamly-processLike 48 but use the specified configuration to run the process.4streamly-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  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-release5streamly-processLike 4 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-release6streamly-processLike 4 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-release7streamly-process+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-release8streamly-processLike 98 but use the specified configuration to run the process.9streamly-process-toChunks "echo hello world" & Stdio.putChunks hello world Pre-release:streamly-process+toChars "echo hello world" & Stdio.putChars hello world Pre-release;streamly-processtoLines Fold.toList "echo -e hello\\\\nworld" & Stream.fold Fold.toList["hello","world"] Pre-release<streamly-processtoString "echo hello world""hello world\n" Pre-release=streamly-processtoStdout "echo hello world" hello world Pre-release>streamly-processtoNull "echo hello world" Pre-release?streamly-processLaunch a standlone process i.e. the process does not have a way to attach the IO streams with other processes. The IO streams stdin, stdout, stderr can either be inherited from the parent or closed.This API is more powerful than  interactive and A and can be used to implement both of these. However, it should be used carefully e.g. if you inherit the IO streams and parent is not waiting for the child process to finish then both parent and child may use the IO streams resulting in garbled IO if both are reading/writing simultaneously.1If the parent chooses to wait for the process an L is returned otherwise a M is returned which can be used to terminate the process, send signals to it or wait for it to finish.@streamly-processLaunch a process interfacing with the user. User interrupts are sent to the launched process and ignored by the parent process. The launched process inherits stdin, stdout, and stderr from the parent, so that the user can interact with the process. The parent waits for the child process to exit, an L' is returned when the process finishes.This is the 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.Astreamly-processLaunch a daemon process. Closes stdin, stdout and stderr, creates a new session, detached from the terminal, the parent does not wait for the process to finish.The M returned can be used to terminate the daemon or send signals to it. 3streamly-processConfig modifierstreamly-processCommandstreamly-process Input streamstreamly-process Output stream8streamly-processConfig modifierstreamly-processCommandstreamly-process Output stream;streamly-processCommandstreamly-process Output Stream<streamly-processCommand=streamly-processCommand>streamly-processCommand?streamly-processWait for process to finish?streamly-processclose (stdin, stdout, stderr)streamly-processCommand@streamly-processCommandAstreamly-processCommand/0123456789:;<=>?@A798:;<=>5643?@A/102!(c) 2023 Composewell Technologies Apache-2.0streamly@composewell.com experimentalGHC Safe-InferredT 3456789:;<=>?@A   798:;<=>4356@A?!(c) 2020 Composewell Technologies Apache-2.0streamly@composewell.com experimentalGHC Safe-InferredT&  !"#$%&'()*,&   #!$%&'( "*,)      !"#$%&'()*+,-./0123456!%#'()*+,-.0789:;<=;<>?@A8BC8BD8BE8FGHIJK-streamly-process-0.3.1-9ilE7ZW8dmVKg8go3aEPwS Streamly.Internal.System.Process Streamly.Internal.System.CommandStreamly.System.CommandStreamly.System.ProcessProcessFailureSessionInheritSession NewSession NewConsoleConfigsetCwdsetEnv closeFilesnewProcessGroup setSession setUserId setGroupIdinterruptChildOnlyparentIgnoresInterruptwaitForDescendantswaitForChildTree pipeStdErr inheritStdin inheritStdoutpipeChunksEitherWithpipeChunksEitherpipeBytesEitherpipeChunksWith pipeChunks processChunks pipeBytes processBytes pipeCharstoChunksEitherWith toChunksWith toBytesEithertoBytestoChunksEithertoChunkstoCharstoLinestoStringtoStdouttoNull standalone foreground interactivedaemon$fExceptionProcessFailure$fShowProcessFailure quotedWord streamWithrunWithpipeWithmkConfigbase GHC.MaybeNothingghc-prim GHC.TypesFalseTrue cleanupNormalcleanupException createProc' Data.EitherLeftEitherRightGHC.IO.ExceptionExitCodeprocess-1.6.13.2System.Process.Common ProcessHandlepipeChunksWithAction