Process module

create_process

procedure · 1 overloadSource

Starts the program args[0] with the arguments args[1..] and returns true once it is running; the result comes later from get_process_result. process must be a fresh Process.

create_process :: (
    process: *Process,
    args: ..string,
    working_directory := "",
    capture_and_return_output := false,
    arg_quoting := Process_Argument_Quoting.QUOTE_IF_NEEDED,
    kill_process_if_parent_exits := true
) -> success: bool

The arguments become one command line, quoted as arg_quoting says, with a limit of 32766 UTF-16 units. It returns false when there is no program name, when process is in use, when the command line is too long or the program cannot be started. The program is searched for the way CreateProcess does, so give a full path or a name with .exe.

  • working_directory, if not empty, becomes the child's current directory.
  • With capture_and_return_output the child's output and error are pipes you read from the Process; without it the child shares this program's own. Its input is always a pipe.
  • With kill_process_if_parent_exits (the default) the child is in a job object that kills it if this program ends; turn it off for a child that should live on.

A child that fills an output pipe nobody reads blocks until someone does, so read with read_from_process while it runs.

Parameters

process: *Process
args: ..string
working_directory := ""
capture_and_return_output := false
arg_quoting := Process_Argument_Quoting.QUOTE_IF_NEEDED
kill_process_if_parent_exits := true

Returns

success: bool

See also