nupp.runtime.services.process

Provider protocol for host.process API 1.

Importing service defines the contract without starting a child. Select a named implementation before requiring nupp.io.process. Every operation receives the retained provider table as its first argument. Options, Exit, and Interest use the canonical declarations in nupp.io.process.types.

Spawn returns the child owner, optional stdin/stdout/stderr handles, process ID, and optional failure message. Pipes and process lifetime are separate resources: closeStream releases a pipe, while reap releases the child owner after settlement. Construct exit results with nupp.io.process.types.exited so callers receive the shared identity and timeout/killed semantics.

Readiness probes must distinguish pending input from EOF and backpressure from a closed pipe. waitReady services the requested read/write interests and child completion for a bounded interval; now supplies its monotonic millisecond clock. Process cleanup must remain valid after cancellation, kill, and partial spawn.

Module contents

Types

TypeKindDescription
Providerinterface

Values

ValueKindDescription
servicevariableCanonical host.process API 1 handle; setup selects before the public facade loads.

Types#

Providerinterface#

interface Provider
    readonly spawn: function(Provider, Options): (any?, any?, any?, any?, integer, string?)
    readonly poll: function(Provider, any): (Exit?)
    readonly kill: function(Provider, any, boolean): nil
    readonly read: function(Provider, any, integer): (string?)
    readonly write: function(Provider, any, string): (integer, boolean)
    readonly closeStream: function(Provider, any): (boolean, string?)
    readonly reap: function(Provider, any): (boolean, string?)
    readonly now: function(Provider): number
    readonly waitReady: function(Provider, Interest, number): integer
end

Methods

spawn#
spawn: function(Provider, Options): (any?, any?, any?, any?, integer, string?)

Returns child, stdin, stdout, stderr, pid, and error in that order. Absent or inherited pipes have nil handles; failure has no child owner.

Arguments
NameTypeDescription
?Provider
?Options
Returns
TypeDescription
any?
any?
any?
any?
integer
string?
poll#
poll: function(Provider, any): (Exit?)

Returns the canonical Exit once available, or nil while the child runs.

Arguments
NameTypeDescription
?Provider
?any
Returns
TypeDescription
Exit?
kill#
kill: function(Provider, any, boolean): nil

Requests termination; the boolean chooses forced termination. The child still requires settlement and reap.

Arguments
NameTypeDescription
?Provider
?any
?boolean
Returns
TypeDescription
nil
read#
read: function(Provider, any, integer): (string?)

Reads at most the requested byte count. An empty string means pending; nil means EOF. Report transport failures by raising.

Arguments
NameTypeDescription
?Provider
?any
?integer
Returns
TypeDescription
string?
write#
write: function(Provider, any, string): (integer, boolean)

Returns accepted bytes and whether the pipe is gone. Zero bytes with false means backpressure; true means the pipe is closed.

Arguments
NameTypeDescription
?Provider
?any
?string
Returns
TypeDescription
integer
boolean
closeStream#
closeStream: function(Provider, any): (boolean, string?)

Releases one pipe handle; repeated release must be harmless.

Arguments
NameTypeDescription
?Provider
?any
Returns
TypeDescription
boolean
string?
reap#
reap: function(Provider, any): (boolean, string?)

Releases the settled child owner; repeated release must be harmless.

Arguments
NameTypeDescription
?Provider
?any
Returns
TypeDescription
boolean
string?
now#
now: function(Provider): number

Returns monotonic milliseconds for process deadlines.

Arguments
NameTypeDescription
?Provider
Returns
TypeDescription
number
waitReady#
waitReady: function(Provider, Interest, number): integer

Waits for the Interest read/write sets or child completion up to the requested millisecond interval, returning the number of ready interests.

Arguments
NameTypeDescription
?Provider
?Interest
?number
Returns
TypeDescription
integer

Values#

servicevariable#

const service: services.Service<Provider>

Canonical host.process API 1 handle; setup selects before the public facade loads.