Process

GitHub   Edit on GitHub

Utilities for accessing functionality and information about the Grain program’s process.

This includes things like accessing environment variables and sending signals.

1
from "wasi/process" include Process

Types

Type declarations included in the Process module.

Process.Signal

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
enum Signal {
HUP,
INT,
QUIT,
ILL,
TRAP,
ABRT,
BUS,
FPE,
KILL,
USR1,
SEGV,
USR2,
PIPE,
ALRM,
TERM,
CHLD,
CONT,
STOP,
TSTP,
TTIN,
TTOU,
URG,
XCPU,
XFSZ,
VTALRM,
PROF,
WINCH,
POLL,
PWR,
SYS,
}

Signals that can be sent to the host system.

Variants:

1
HUP

Hangup.

1
INT

Terminate interrupt signal.

1
QUIT

Terminal quit signal.

1
ILL

Illegal instruction.

1
TRAP

Trace/breakpoint trap.

1
ABRT

Process abort signal.

1
BUS

Access to an undefined portion of a memory object.

1
FPE

Erroneous arithmetic operation.

1
KILL

Kill.

1
USR1

User-defined signal 1.

1
SEGV

Invalid memory reference.

1
USR2

User-defined signal 2.

1
PIPE

Write on a pipe with no one to read it.

1
ALRM

Alarm clock.

1
TERM

Termination signal.

1
CHLD

Child process terminated, stopped, or continued.

1
CONT

Continue executing, if stopped.

1
STOP

Stop executing.

1
TSTP

Terminal stop signal.

1
TTIN

Background process attempting read.

1
TTOU

Background process attempting write.

1
URG

High bandwidth data is available at a socket.

1
XCPU

CPU time limit exceeded.

1
XFSZ

File size limit exceeded.

1
VTALRM

Virtual timer expired.

1
SYS

Bad system call.


Values

Functions and constants included in the Process module.

Process.argv

1
argv : () => Result<Array<String>, Exception>

Access command line arguments.

Returns:

type description
Result<Array<String>, Exception> Ok(args) of an array containing positional string arguments to the process if successful or Err(exception) otherwise

Process.env

1
env : () => Result<Array<String>, Exception>

Access environment variables.

Returns:

type description
Result<Array<String>, Exception> Ok(vars) of an array containing environment variables supplied to the process if successful or Err(exception) otherwise

Process.exit

1
exit : (code: Number) => Result<Void, Exception>

Terminate the process normally.

Parameters:

param type description
code Number The value to exit with. An exit code of 0 is considered normal, with other values having meaning depending on the platform

Returns:

type description
Result<Void, Exception> Err(exception) if unsuccessful. Will not actually return a value if successful, as the process has ended

Process.sigRaise

1
sigRaise : (signal: Signal) => Result<Void, Exception>

Send a signal to the process of the calling thread.

Parameters:

param type description
signal Signal The signal to send

Returns:

type description
Result<Void, Exception> Ok(void) if successful or Err(exception) otherwise

Process.schedYield

1
schedYield : () => Result<Void, Exception>

Yield execution to the calling thread.

Returns:

type description
Result<Void, Exception> Ok(void) if successful or Err(exception) otherwise
This is a notification!