Skip to content

proc

The proc module provides functions and objects for process invocation and output capture.

Types

Name Description
Error Error raised when a process exits unsuccessfully

Functions

with_policy func :signal? :grace? :force? ...

Runs a callable with temporary process termination defaults.

Parameters:

Name Type Description
func func Callable to execute
signal sym Unix signal name (default: :TERM:)
grace Duration|float Time before forced termination (default: 5 seconds)
force bool Force termination after the grace period
... Additional arguments passed to func

Returns:

The return value of func.

The signal setting is retained when the strand later targets a Unix VFS. Windows launches always use CTRL_BREAK_EVENT. With force: false, a process that outlives the grace period is orphaned.

with_policy signal: :INT: grace: 2.5 do
  run worker

sub func :trim?

Captures the output of a function as a string.

External process output is captured as a byte stream without line decoding or normalization. Value writes still cross the sink boundary and follow the current I/O mode.

Parameters

Name Type Description
func func function whose output to capture
trim Bool Remove one trailing LF or CRLF (default: true)

Returns

Str

let output = sub do run echo hello
assert_eq $output "hello"