Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow non-portable and signal values as exit statuses. #235

Merged
merged 3 commits into from
Mar 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions phases/ephemeral/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -2389,9 +2389,12 @@ The number of events stored.
---

#### <a href="#exit" name="exit"></a> `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
- <a href="#exit.rval" name="exit.rval"></a> `rval`: [`exitcode`](#exitcode)
Expand Down
14 changes: 12 additions & 2 deletions phases/ephemeral/witx/typenames.witx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions phases/ephemeral/witx/wasi_ephemeral_proc.witx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down