diff --git a/phases/ephemeral/docs.md b/phases/ephemeral/docs.md index e7a3aa91..555d74e2 100644 --- a/phases/ephemeral/docs.md +++ b/phases/ephemeral/docs.md @@ -2389,9 +2389,12 @@ The number of events stored. --- #### `exit(rval: exitcode)` -Terminate the process normally. An exit code of 0 indicates successful -termination of the program. The meanings of other values is dependent on -the environment. +Terminate the process normally. An exit code of `$exitcode::success` +reports successful completion of the program. An exit code of +`$exitcode::failure` or any other value less than 126 reports a +failure, and the value is provided to the environment. If a value +of 126 or greater is given, this function behaves as if it were +implemented by an `unreachable` instruction. ##### Params - `rval`: [`exitcode`](#exitcode) diff --git a/phases/ephemeral/witx/typenames.witx b/phases/ephemeral/witx/typenames.witx index 1f9abc59..bbd6489d 100644 --- a/phases/ephemeral/witx/typenames.witx +++ b/phases/ephemeral/witx/typenames.witx @@ -638,8 +638,18 @@ ) ) -;;; Exit code generated by a process when exiting. -(typename $exitcode u32) +;;; Exit code generated by a program when exiting. +(typename $exitcode u8) + +;;; Indicate the program exited successfully. +;;; +;;; Note: This is similar to `EXIT_SUCCESS` in POSIX. +(@witx const $exitcode $success 0) + +;;; Indicate the program exited unsuccessfully. +;;; +;;; Note: This is similar to `EXIT_FAILURE` in POSIX. +(@witx const $exitcode $failure 1) ;;; Flags provided to `sock_recv`. (typename $riflags diff --git a/phases/ephemeral/witx/wasi_ephemeral_proc.witx b/phases/ephemeral/witx/wasi_ephemeral_proc.witx index 0507d4ff..0bd57682 100644 --- a/phases/ephemeral/witx/wasi_ephemeral_proc.witx +++ b/phases/ephemeral/witx/wasi_ephemeral_proc.witx @@ -8,9 +8,12 @@ (use "typenames.witx") (module $wasi_ephemeral_proc - ;;; Terminate the process normally. An exit code of 0 indicates successful - ;;; termination of the program. The meanings of other values is dependent on - ;;; the environment. + ;;; Terminate the process normally. An exit code of `$exitcode::success` + ;;; reports successful completion of the program. An exit code of + ;;; `$exitcode::failure` or any other value less than 126 reports a + ;;; failure, and the value is provided to the environment. If a value + ;;; of 126 or greater is given, this function behaves as if it were + ;;; implemented by an `unreachable` instruction. (@interface func (export "exit") ;;; The exit code returned by the process. (param $rval $exitcode)