Index wasi args_get args_sizes_get clock_res_get clock_time_get environ_get environ_sizes_get fd_advise fd_allocate fd_close fd_datasync fd_fdstat_get fd_fdstat_set_flags fd_fdstat_set_rights fd_filestat_get fd_filestat_set_size fd_filestat_set_times fd_pread fd_prestat_dir_name fd_prestat_get fd_pwrite fd_read fd_readdir fd_renumber fd_seek fd_sync fd_tell fd_write file_stat_flags filestat iovec lookup_flags path_create_directory path_filestat_get path_filestat_set_times path_link path_open path_readlink path_remove_directory path_rename path_symlink path_unlink_file poll_oneoff proc_exit proc_raise random_get sched_yield sock_accept sock_recv sock_send sock_shutdown
Terminate the process normally. An exit code of 0 indicates successful termination of the program. The meanings of other values are dependent on the environment.
proc_exit (
code: i32The exit code to return to the operating system
) =>
error: i32 

The proc_exit() function is similar to the exit() function in POSIX systems. It allows the program to gracefully terminate with an exit code. The provided exit code is returned to the operating system.

Notes

  • The behavior of proc_exit() is similar to the POSIX exit() function, which terminates the calling process.
  • The exit() function in POSIX does not have a return value, as the termination of the process is immediate.
  • It is important to note that proc_exit() is specific to the WASIX system call toolchain for WebAssembly and may have slight differences from the POSIX exit() function.
  • In POSIX systems, the exit() function is usually called at the end of the program or when an error occurs that requires immediate termination.
  • The exit code returned by proc_exit() can be used by the parent process or by the operating system to determine the status of the terminated process.
  • The meanings of exit codes other than 0 depend on the specific environment or application. In POSIX systems, non-zero exit codes are often used to indicate different types of errors or exceptional conditions.
  • When writing portable code, it is important to consider the exit code meanings in the target environment and ensure proper handling of different exit codes.

Read More