Class representing a spawned process.
Variables
read onlymessageSignal:Signal<IpcMessage>
Emitted when a message is received over IPC. The process must be created
with an Ipc entry in options.stdio; see Process.spawn.
read onlypid:Int
Process identifier of this process. A PID uniquely identifies a process
on its host machine for the duration of its lifetime.
stdio:Array<Socket>
Pipes created between the current (host) process and this (spawned)
process. The order corresponds to the ProcessIO specifiers in
options.stdio in spawn. This array can be used to access non-standard
pipes, i.e. file descriptors 3 and higher, as well as file descriptors 0-2
with non-standard read/write access.
Methods
send (message:IpcMessage):Void
Send data to the process over the IPC channel. The process must be
created with an Ipc entry in options.stdio; see Process.spawn.
Static methods
staticspawn (command:String, ?args:Array<String>, ?options:ProcessSpawnOptions):Process
Execute the given command with args (none by default). options can be
specified to change the way the process is spawned.
options.stdio is an optional array of ProcessIO specifications which
can be used to define the file descriptors for the new process:
Ignore- skip the current position. No stream or pipe will be open for this index.Inherit- inherit the corresponding file descriptor from the current process. Shares standard input, standard output, and standard error in index 0, 1, and 2, respectively. In index 3 or higher,Inherithas the same effect asIgnore.Pipe(readable, writable, ?pipe)- create or use a pipe.readableandwritablespecify whether the pipe will be readable and writable from the point of view of the spawned process. Ifpipeis given, it is used directly, otherwise a new pipe is created.Ipc- create an IPC (inter-process comunication) pipe. Only one may be specified inoptions.stdio. This special pipe will not have an entry in thestdioarray of the resulting process; instead, messages can be sent using thesendmethod, and received overmessageSignal. IPC pipes allow sending and receiving structured Haxe data, as well as connected sockets and pipes.
Pipes are made available in the stdio array afther the process is
spawned. Standard file descriptors have their own variables:
stdin- set to point to a pipe in index 0, if it exists and is read-only for the spawned process.stdout- set to point to a pipe in index 1, if it exists and is write-only for the spawned process.stderr- set to point to a pipe in index 2, if it exists and is write-only for the spawned process.
If options.stdio is not given,
[Pipe(true, false), Pipe(false, true), Pipe(false, true)] is used as a
default.
Parameters:
options.cwd | Path to the working directory. Defaults to the current working directory if not given. |
|---|---|
options.env | Environment variables. Defaults to the environment variables of the current process if not given. |
options.argv0 | First entry in the |
options.stdio | Array of |
options.detached | When |
options.uid | User identifier. |
options.gid | Group identifier. |
options.windowsVerbatimArguments | (Windows only.) Do not perform automatic quoting or escaping of arguments. |
options.windowsHide | (Windows only.) Automatically hide the window of the spawned process. |