XU XUv0.16.0

#os/exec

import: #os/exec

counts: 3 functions, 11 methods, 1 types, 0 constants, 0 method sets

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

Structure encapsulating path, args, dir, ctx, has_ctx.

Public fields

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

($&Cmd) set_dir

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

Purpose

Operation on $&Cmd: set dir.

Parameters

c $&Cmd
The Cmd instance used by this call (exclusive borrow).
dir string
directory (string)

Returns

This call does not return a value.

command

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

Purpose

Execute command.

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; handle the error or propagate it to the caller.

Parameters

file string
file (string)

Returns

string — result string

(&Cmd) run_status

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

Purpose

run_status returns the child status while still throwing on launch, cancellation, and wait errors. Throws on failure; handle the error or propagate it to the caller.

Parameters

c &Cmd
The Cmd instance used by this call (borrow).

Returns

int — a value of this type

(&Cmd) run

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

Purpose

Execute run on &Cmd. Throws on failure; handle the error or propagate it to the caller.

Parameters

c &Cmd
The Cmd instance used by this call (borrow).

Returns

int — a value of this type

(&Cmd) output

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

Purpose

Execute output on &Cmd. Throws on failure; handle the error or propagate it to the caller.

Parameters

c &Cmd
The Cmd instance used by this call (borrow).

Returns

string — result string

($&Cmd) close_unstarted_pipes

XuAPI
pub fn (c $&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 $&Cmd
The Cmd instance used by this call (exclusive borrow).

Returns

This call does not return a value.

($&Cmd) stdout_pipe

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

Purpose

Operation on $&Cmd: stdout pipe. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&Cmd
The Cmd instance used by this call (exclusive borrow).

Returns

os.File — a value of this type

($&Cmd) stderr_pipe

XuAPI
pub fn (c $&Cmd) stderr_pipe() os.File

Purpose

Operation on $&Cmd: stderr pipe. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&Cmd
The Cmd instance used by this call (exclusive borrow).

Returns

os.File — a value of this type

($&Cmd) stdin_pipe

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

Purpose

Operation on $&Cmd: stdin pipe. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&Cmd
The Cmd instance used by this call (exclusive borrow).

Returns

os.File — a value of this type

($&Cmd) start

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

Purpose

Execute start on $&Cmd. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&Cmd
The Cmd instance used by this call (exclusive borrow).

Returns

int — a value of this type

($&Cmd) wait

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

Purpose

Execute wait on $&Cmd. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&Cmd
The Cmd instance used by this call (exclusive borrow).

Returns

int — a value of this type

(&Cmd) combined_output

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

Purpose

Operation on &Cmd: combined output. Throws on failure; handle the error or propagate it to the caller.

Parameters

c &Cmd
The Cmd instance used by this call (borrow).

Returns

string — result string