Functions for starting a process.
Code Map
//! Functions for starting a process.
module watt.process.spawn;
//! Serves as a handle to a spawned process.
class Pid
{
public:
alias OsHandle = pid_t;
alias _pid = osHandle;
alias NativeID = OsHandle;
public:
osHandle: OsHandle;
public:
this(osHandle: OsHandle) { }
//! Wait for this process to finish, and get the return value.
fn wait() i32 { }
}
//! Thrown if a process could not be spawned.
class ProcessException : Exception
{
public:
this(msg: string) { }
}
//! Search the current working directory and PATH for the given command.
fn getCommandFromName(name: string) string { }
//! Start a process from the executable name and with the given args.
fn spawnProcess(name: string, args: string[]) Pid { }
//! Start a process from an executable.
fn spawnProcess(name: string, args: string[], inputStream: InputStdcStream, outputStream: OutputStdcStream, errorStream: OutputStdcStream, env: Environment) Pid { }
//! Start a process from an executable.
fn spawnProcess(name: string, args: string[], inputStream: InputFDStream, outputStream: OutputFDStream, errorStream: OutputFDStream, env: Environment) Pid { }
fn spawnProcess(name: string, args: string[], _stdin: FILE*, _stdout: FILE*, _stderr: FILE*, env: Environment) Pid { }
//! Search a PATH string for a command. If one is not given, PATH will be
//! retrieved and used.
fn searchPath(cmd: string, path: string) string { }
//! Get an environmental variable, or "" if it doesn't exist.
fn getEnv(env: string) string { }
//! Run a command through the libc system function.
fn system(name: string) i32 { }
fn spawnProcessPosix(name: string, args: string[], stdinFD: i32, stdoutFD: i32, stderrFD: i32, env: Environment) i32 { }
//! Wait for a specific process.
fn waitPosix(pid: pid_t) i32 { }
//! Wait for a process.
fn waitManyPosix(pid: pid_t) i32 { }
Serves as a handle to a spawned process.
Usually you will not construct these, but will get them from spawnProcess.
Wait for this process to finish, and get the return value.
Thrown if a process could not be spawned.
Search the current working directory and PATH for the given command.
Start a process from the executable name
and with the given args
.
Example
pid := spawnProcess("volta", ["-c", "test.volt"]);
pid.wait(); // Blocks until the process is finished.
Start a process from an executable.
Parameters
name | |
args | |
inputStream |
Standard input will be read from this stream. If this is
|
outputStream |
Standard output will be written to this stream. If this is |
errorStream |
Standard error will be written to this stream. If this is |
env |
Return
A Pid
instance for the new process.
Throws
-
ProcessException
if a process could not be spawned for some reason.
Search a PATH string for a command. If one is not given, PATH will be retrieved and used.
Get an environmental variable, or ""
if it doesn't exist.
Run a command through the libc system
function.
Wait for a specific process.
Wait for a process.