# `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. ## Types ### `Provider` _interface_ ```nupp 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` ```nupp 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 | Name | Type | Description | | --- | --- | --- | | `?` | `Provider` | | | `?` | `Options` | | ###### Returns | Type | Description | | --- | --- | | `any?` | | | `any?` | | | `any?` | | | `any?` | | | `integer` | | | `string?` | | ##### `poll` ```nupp poll: function(Provider, any): (Exit?) ``` Returns the canonical Exit once available, or nil while the child runs. ###### Arguments | Name | Type | Description | | --- | --- | --- | | `?` | `Provider` | | | `?` | `any` | | ###### Returns | Type | Description | | --- | --- | | `Exit?` | | ##### `kill` ```nupp kill: function(Provider, any, boolean): nil ``` Requests termination; the boolean chooses forced termination. The child still requires settlement and reap. ###### Arguments | Name | Type | Description | | --- | --- | --- | | `?` | `Provider` | | | `?` | `any` | | | `?` | `boolean` | | ###### Returns | Type | Description | | --- | --- | | `nil` | | ##### `read` ```nupp 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 | Name | Type | Description | | --- | --- | --- | | `?` | `Provider` | | | `?` | `any` | | | `?` | `integer` | | ###### Returns | Type | Description | | --- | --- | | `string?` | | ##### `write` ```nupp 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 | Name | Type | Description | | --- | --- | --- | | `?` | `Provider` | | | `?` | `any` | | | `?` | `string` | | ###### Returns | Type | Description | | --- | --- | | `integer` | | | `boolean` | | ##### `closeStream` ```nupp closeStream: function(Provider, any): (boolean, string?) ``` Releases one pipe handle; repeated release must be harmless. ###### Arguments | Name | Type | Description | | --- | --- | --- | | `?` | `Provider` | | | `?` | `any` | | ###### Returns | Type | Description | | --- | --- | | `boolean` | | | `string?` | | ##### `reap` ```nupp reap: function(Provider, any): (boolean, string?) ``` Releases the settled child owner; repeated release must be harmless. ###### Arguments | Name | Type | Description | | --- | --- | --- | | `?` | `Provider` | | | `?` | `any` | | ###### Returns | Type | Description | | --- | --- | | `boolean` | | | `string?` | | ##### `now` ```nupp now: function(Provider): number ``` Returns monotonic milliseconds for process deadlines. ###### Arguments | Name | Type | Description | | --- | --- | --- | | `?` | `Provider` | | ###### Returns | Type | Description | | --- | --- | | `number` | | ##### `waitReady` ```nupp 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 | Name | Type | Description | | --- | --- | --- | | `?` | `Provider` | | | `?` | `Interest` | | | `?` | `number` | | ###### Returns | Type | Description | | --- | --- | | `integer` | | ## Values ### `service` _variable_ ```nupp const service: services.Service ``` Canonical host.process API 1 handle; setup selects before the public facade loads.