Exit status
In computing, the exit status (also exit code or exit value) of a terminated process is an integer number that is made available to its parent process (or caller).[src] In DOS, this may be referred to as an errorlevel.[src] When computer programs are executed, the operating system creates an abstract entity called a process in which the book-keeping for that program is maintained.[src] In multitasking operating systems such as Unix or Linux, new processes can be created by active processes.[src] The process that spawns another is called a parent process, while those created are child processes.[src] Child processes run concurrently with the parent process.[src] The technique of spawning child processes is used to delegate some work to a child process when there is no reason to stop the execution of the parent.[src] When the child finishes executing, it exits by calling the exit system call.[src] This system call facilitates passing the exit status code back to the parent, which can retrieve this value using the wait system call.[src]
In computing, the exit status (also exit code or exit value) of a terminated process is an integer number that is made available to its parent process (or caller).[src] In DOS, this may be referred to as an errorlevel.[src] When computer programs are executed, the operating system creates an abstract entity called a process in which the book-keeping for that program is maintained.[src] In multitasking operating systems such as Unix or Linux, new processes can be created by active processes.[src] The process that spawns another is called a parent process, while those created are child processes.[src] Child processes run concurrently with the parent process.[src] The technique of spawning child processes is used to delegate some work to a child process when there is no reason to stop the execution of the parent.[src] When the child finishes executing, it exits by calling the exit system call.[src] This system call facilitates passing the exit status code back to the parent, which can retrieve this value using the wait system call.[src] ==Semantics== The parent and the child can have an understanding about the meaning of the exit statuses.[src] For example, it is common programming practice for a child process to return (exit with) zero to the parent signifying success.[src] Apart from this return value from the child, other information like how the process exited, either normally or by a signal may also be available to the parent process.[src] The specific set of codes returned is unique to the program that sets it.[src] Typically it indicates success or failure.[src] The value of the code returned by the function or program may indicate a specific cause of failure.[src] On many systems, the higher the value, the more severe the cause of the error.[src] Alternatively, each bit may indicate a different condition, with these being evaluated by the or operator together to give the final value; for example, fsck does this.[src] Sometimes, if the codes are designed with this purpose in mind, they can be used directly as a branch index upon return to the initiating program to avoid additional tests.[src] ===AmigaOS=== In AmigaOS, MorphOS and AROS, four levels are defined: ===Shell and scripts=== Shell scripts typically execute commands and capture their exit statuses.[src] For the shell's purposes, a command which exits with a zero exit status has succeeded.[src] A nonzero exit status indicates failure.[src] This seemingly counter-intuitive scheme is used so there is one well-defined way to indicate success and a variety of ways to indicate various failure modes.[src] When a command is terminated by a signal whose number is , a shell sets the variable to a value greater than 128.[src] Most shells use , while ksh93 uses .[src] If a command is not found, the shell should return a status of .[src] If a command is found but is not executable, the return status should be .[src] Note that this is not the case for all shells.[src] If a command fails because of an error during expansion or redirection, the exit status is greater than zero.[src] ===C and C++=== The C and C++ programming languages allow programs exiting or returning from the main function to signal success or failure by returning an integer, or returning the macros EXIT_SUCCESS and EXIT_FAILURE .[src] On Unix-like systems these are equal to 0 and 1 respectively.[src] A C program may also use the exit() function specifying the integer status or exit macro as the first parameter, which halts the program.[src] The return value from main is passed to the exit function, which for values zero, EXIT_SUCCESS or EXIT_FAILURE may translate it to "an implementation defined form" of successful termination or unsuccessful termination.[src] Apart from 0 and the macros EXIT_SUCCESS and EXIT_FAILURE , the C standard does not define the meaning of return codes.[src] Rules for the use of return codes vary on different platforms (see the platform-specific sections).[src] ===C#=== In C#, the Main() method typically does not return a type (its type is void , or if async , it is System.Threading.Tasks.Task ).[src] However, Main() may indicate a return type, of type int , which is returned to the operating system.[src] If the Main() method is declared async , then it instead returns System.Threading.Tasks.Task .[src] ===DOS=== In DOS terminology, an errorlevel is an integer exit code returned by an executable program or subroutine.[src] Errorlevels typically range from to .[src] In DOS there are only 256 error codes available, but DR DOS 6.0 and higher support 16-bit error codes at least in .[src] With 4DOS and DR-DOS , exit codes (in batchjobs) can be set by and (in ) through .[src] Exit statuses are often captured by batch programs through commands.[src] Multiuser DOS supports a reserved environment variable %ERRORLVL% which gets automatically updated on return from applications.[src] under DR-DOS 7.02 and higher supports a similar pseudo-environment variable as well as .[src] In , DR DOS 6.0 and higher supports to test the load status and return code of device drivers and the exit code of programs.[src] ===Java=== In Java, the main() does not indicate an exit code, so if needed, an exit code is manually specified through java.lang.System::exit() , which terminates the program and the JVM.[src] Any method may call System.exit() , unless a security manager does not permit it.[src] The argument serves as a status code; by convention, a nonzero status code indicates abnormal termination.[src] ===OpenVMS=== In OpenVMS, success is indicated by odd values and failure by even values.[src] The value is a 32-bit integer with sub-fields: control bits, facility number, message number and severity.[src] Severity values are divided between success (Success, Informational) and failure (Warning, Error, Fatal).[src] ===Plan 9=== In Plan 9's C, exit status is indicated by a string passed to the function, and function is type .[src] ===POSIX=== In Unix and other POSIX-compatible systems, the parent process can retrieve the exit status of a child process using the wait() family of system calls defined in POSIX header .[src] Of these, the waitid() call retrieves the full exit status, but the older wait() and waitpid() calls retrieve only the least significant 8 bits of the exit status.[src] The wait() and waitpid() interfaces set a status value of type int packed as a bitfield with various types of child termination information.[src] If the child terminated by exiting (as determined by the WIFEXITED() macro; the usual alternative being that it died from an uncaught signal), SUS specifies that the low-order 8 bits of the exit status can be retrieved from the status value using the WEXITSTATUS() macro.[src] In the waitid() system call (added with SUSv1), the child exit status and other information are no longer in a bitfield but in the structure of type siginfo_t .[src] POSIX-compatible systems typically use a convention of zero for success and nonzero for error.[src] Some conventions have developed as to the relative meanings of various error codes; for example GNU recommend that codes with the high bit set be reserved for serious errors.[src] BSD-derived OS's have defined an extensive set of preferred interpretations: Meanings for 15 status codes 64 through 78 are defined in POSIX header .[src] These historically derive from sendmail and other message transfer agents, but they have since found use in many other programs.[src] It has been deprecated and its use is discouraged.[src] The Advanced Bash-Scripting Guide has some information on the meaning of non-0 exit status codes.[src] ===Rust=== In Rust, main() may return any type that implements the trait std::process::Termination .[src] Internally on the Rust runtime, these will return libc::EXIT_SUCCESS upon successful execution and libc::EXIT_FAILURE upon failure.[src] In the Rust standard library, the following types have implementations for std::process::Termination : ![src] (the never type) () (the unit type) std::convert::Infallible std::process::ExitCode (with constants SUCCESS and FAIL ) std::result::Result ===VM/CMS=== ===Windows=== Microsoft Windows uses 32-bit unsigned integers as exit codes, although the command interpreter treats them as signed.[src] Exit codes are directly referenced, for example, by the command line interpreter CMD.exe in the errorlevel terminology inherited from DOS.[src] The .NET Framework processes and the Windows PowerShell refer to it as the ExitCode property of the Process object.[src] ==See also== Error code Return statement true and false (commands) ==References==[src]
79 sentences · 79 cited inline · 0 references stored
References
No reference rows published for this article.
Cite this article
MLA
"Exit status." encyclopegia.org, 2026, https://encyclopegia.org/wiki/exit-status. Accessed 30 November 2026.
Chicago
"Exit status." encyclopegia.org. Accessed November 30, 2026. https://encyclopegia.org/wiki/exit-status.
APA
encyclopegia.org. (2026). Exit status. Retrieved November 30, 2026, from https://encyclopegia.org/wiki/exit-status
Accessed November 30, 2026 · CC BY-SA 4.0 · citation page · JSON