std.process
abort
pub fn abort()
[src]
pub fn abort() {
_process.abort();
}
Terminates the process in an abnormal fashion.
abort
pub fn abort()
[src]
pub fn abort() {
_process.abort();
}
Terminates the process in an abnormal fashion.
Terminates the process in an abnormal fashion.
See also: https://doc.rust-lang.org/std/process/fn.abort.html
[src]
pub fn args(): [string] {
return _process.args();
}
Return a [string]
of the arguments passed to the process.
[src]
pub fn args(): [string] {
return _process.args();
}
Return a [string]
of the arguments passed to the process.
Return a [string]
of the arguments passed to the process.
use std.process;
fn main() {
process.args(); // ["navi", "hello", "world"]
}
exec
pub fn exec(program: string, current_dir: string? = nil, args: [string]? = nil, envs: <string, string>? = nil, stdin: string? = "piped", stdout: string? = "piped", stderr: string? = "piped", uid: int? = nil, gid: int? = nil): Output throws IoError
[src]
pub fn exec(
program: string,
current_dir: string? = nil,
args: [string]? = nil,
envs: <string, string>? = nil,
stdin: string? = "piped",
stdout: string? = "piped",
stderr: string? = "piped",
uid: int? = nil,
gid: int? = nil
): Output throws IoError {
let command = build_command(
program,
current_dir:,
args:,
envs:,
stdin:,
stdout:,
stderr:,
uid:,
gid:
);
return try command.exec();
}
Executes the command as a child process, waiting for it to finish and collecting all of its output.
exec
pub fn exec(program: string, current_dir: string? = nil, args: [string]? = nil, envs: <string, string>? = nil, stdin: string? = "piped", stdout: string? = "piped", stderr: string? = "piped", uid: int? = nil, gid: int? = nil): Output throws IoError
[src]
pub fn exec(
program: string,
current_dir: string? = nil,
args: [string]? = nil,
envs: <string, string>? = nil,
stdin: string? = "piped",
stdout: string? = "piped",
stderr: string? = "piped",
uid: int? = nil,
gid: int? = nil
): Output throws IoError {
let command = build_command(
program,
current_dir:,
args:,
envs:,
stdin:,
stdout:,
stderr:,
uid:,
gid:
);
return try command.exec();
}
Executes the command as a child process, waiting for it to finish and collecting all of its output.
Executes the command as a child process, waiting for it to finish and collecting all of its output.
By default, stdout and stderr are captured (and used to provide the resulting output). Stdin is not inherited from the parent and any attempt by the child process to read from the stdin stream will result in the stream immediately closing.
- program: string of program to execute, must be a shell command, can't be a bash script.
Kw Args
current_dir
: Current working directory of the child process.args
: string array [string] to pass to the command.envs
: string map <string, string> variables to set ENV when running the command.stdin
: Stdio of child process's stdin, default topiped
.stdout
: Stdio of child process's stdout, default topiped
.stderr
: Stdio of child process's stderr, default topiped
.uid
: Sets the child process’s user ID. This translates to a setuid call in the child process. Failure in the setuid call will cause the spawn to fail.gid
: Similar to uid, but sets the group ID of the child process. This has the same semantics as the uid field.
Stdio
Defaults to piped
when used with process.exec
.
inherit
: Inherit from parent process.piped
: Create a pipe.null
: Null device.- Or a file path, if path is not exists, it will be created (If create failed will panic).
use std.process;
let output = try! process.exec("echo", args: ["Hello, world!"]);
/// echo Hello, world!
assert_eq output.status, 0;
// Or you can use a string instead of an array
let output = try! process.exec("sh", args: ["-c", "echo Hello, world! && echo Foo Bar"]);
output.stdout.to_string(); // "Hello, world!Foo Bar"
[src]
pub fn exit(code: int) {
_process.exit(code);
}
Terminates the current process with the specified exit code.
[src]
pub fn exit(code: int) {
_process.exit(code);
}
Terminates the current process with the specified exit code.
Terminates the current process with the specified exit code.
See also: https://doc.rust-lang.org/std/process/fn.exit.html
use std.process;
process.exit(0);
[src]
pub fn parent_id(): int {
return _process.parent_id();
}
Returns the OS-assigned process identifier associated with this process’s parent.
[src]
pub fn parent_id(): int {
return _process.parent_id();
}
Returns the OS-assigned process identifier associated with this process’s parent.
Returns the OS-assigned process identifier associated with this process’s parent.
Unix only.
use std.process;
process.parent_id(); // 12345
[src]
pub fn pid(): int {
return _process.pid();
}
Return the current process id.
[src]
pub fn pid(): int {
return _process.pid();
}
Return the current process id.
Return the current process id.
use std.process;
process.pid(); // 12345
run
pub fn run(program: string, current_dir: string? = nil, args: [string]? = nil, envs: <string, string>? = nil, stdin: string? = "inherit", stdout: string? = "inherit", stderr: string? = "inherit", uid: int? = nil, gid: int? = nil): Child throws IoError
[src]
pub fn run(
program: string,
current_dir: string? = nil,
args: [string]? = nil,
envs: <string, string>? = nil,
stdin: string? = "inherit",
stdout: string? = "inherit",
stderr: string? = "inherit",
uid: int? = nil,
gid: int? = nil
): Child throws IoError {
let command = build_command(
program,
current_dir:,
args:,
envs:,
stdin:,
stdout:,
stderr:,
uid:,
gid:
);
return try command.run();
}
Executes the command as a child process, returning a handle to it.
run
pub fn run(program: string, current_dir: string? = nil, args: [string]? = nil, envs: <string, string>? = nil, stdin: string? = "inherit", stdout: string? = "inherit", stderr: string? = "inherit", uid: int? = nil, gid: int? = nil): Child throws IoError
[src]
pub fn run(
program: string,
current_dir: string? = nil,
args: [string]? = nil,
envs: <string, string>? = nil,
stdin: string? = "inherit",
stdout: string? = "inherit",
stderr: string? = "inherit",
uid: int? = nil,
gid: int? = nil
): Child throws IoError {
let command = build_command(
program,
current_dir:,
args:,
envs:,
stdin:,
stdout:,
stderr:,
uid:,
gid:
);
return try command.run();
}
Executes the command as a child process, returning a handle to it.
Executes the command as a child process, returning a handle to it.
This unlike process.exec
does not wait for the child process to finish, unless you call child.wait()
.
See process.exec
for more details.
use std.process;
fn main() throws {
let child = try! process.run("sh -c echo Hello, world!");
try child.wait();
}