XU XUv0.8.8
中文

API

#os/exec

import: #os/exec

counts: 3 fns, 9 methods, 1 types, 0 consts, 0 ifaces

Process execution with argument arrays, run/output/combined_output, start/wait, and stdin/stdout pipes.

struct Cmd

XuAPI
pub struct Cmd {
    pub path string
    pub args []string
    pub dir string
    pub ctx context.Context
    pub has_ctx int
}

Purpose

`os/exec` subset: command / run / output / combined_output command_context / start / wait / stdout_pipe / stdin_pipe. Run is direct exec, not a shell. PATH lookup is look_path. stdout_pipe / stdin_pipe are Unix-only (Windows throws). stdin must be written and the write end closed before start.

Parameters

path string
filesystem path
args []string
variadic arguments
dir string
directory
ctx context.Context
field (context.Context)
has_ctx int
field (int)

(&mut Cmd) set_dir

XuAPI
pub fn (c &mut Cmd) set_dir(dir string)

Purpose

Method on `&mut Cmd`: set dir.

Parameters

c &mut Cmd
receiver &mut Cmd (exclusive borrow)
dir string
directory (string)

command

XuAPI
pub fn command(name string, args <-> string) Cmd

Purpose

command; returns Cmd.

Parameters

name string
name (string)
args <-> string
variadic string (seen inside the function as []string)

Returns

Cmd — a value of this type

command_context

XuAPI
pub fn command_context(ctx context.Context, name string, args <-> string) Cmd

Purpose

Command context.

Parameters

ctx context.Context
ctx (context.Context)
name string
name (string)
args <-> string
variadic string (seen inside the function as []string)

Returns

Cmd — a value of this type

look_path

XuAPI
pub fn look_path(file string) string

Purpose

Look path. Throws on failure.

Parameters

file string
file (string)

Returns

string — result string

(&Cmd) run

XuAPI
pub fn (c &Cmd) run() int

Purpose

Call `run` on `&Cmd`. Throws on failure.

Parameters

c &Cmd
receiver &Cmd (borrow)

Returns

int — a value of this type

(&Cmd) output

XuAPI
pub fn (c &Cmd) output() string

Purpose

Call `output` on `&Cmd`. Throws on failure.

Parameters

c &Cmd
receiver &Cmd (borrow)

Returns

string — result string

(&mut Cmd) close_unstarted_pipes

XuAPI
pub fn (c &mut Cmd) close_unstarted_pipes()

Purpose

Release pipe endpoints when setup fails before start. Once started, the runtime owns the child endpoints; closing those stale fd numbers is unsafe.

Parameters

c &mut Cmd
receiver &mut Cmd (exclusive borrow)

(&mut Cmd) stdout_pipe

XuAPI
pub fn (c &mut Cmd) stdout_pipe() os.File

Purpose

Method on `&mut Cmd`: stdout pipe. Throws on failure.

Parameters

c &mut Cmd
receiver &mut Cmd (exclusive borrow)

Returns

os.File — a value of this type

(&mut Cmd) stdin_pipe

XuAPI
pub fn (c &mut Cmd) stdin_pipe() os.File

Purpose

Method on `&mut Cmd`: stdin pipe. Throws on failure.

Parameters

c &mut Cmd
receiver &mut Cmd (exclusive borrow)

Returns

os.File — a value of this type

(&mut Cmd) start

XuAPI
pub fn (c &mut Cmd) start() int

Purpose

Call `start` on `&mut Cmd`. Throws on failure.

Parameters

c &mut Cmd
receiver &mut Cmd (exclusive borrow)

Returns

int — a value of this type

(&mut Cmd) wait

XuAPI
pub fn (c &mut Cmd) wait() int

Purpose

Call `wait` on `&mut Cmd`. Throws on failure.

Parameters

c &mut Cmd
receiver &mut Cmd (exclusive borrow)

Returns

int — a value of this type

(&Cmd) combined_output

XuAPI
pub fn (c &Cmd) combined_output() string

Purpose

Method on `&Cmd`: combined output. Throws on failure.

Parameters

c &Cmd
receiver &Cmd (borrow)

Returns

string — result string