Exit status

Exit status

The exit status of a process in computer programming is an small number passed from a child process to a parent process when it is done executing a specific task delegated. On DOS, this may be referred to as an errorlevel.

When software programs are run or executed, the operating system creates an abstract entity called a computer process in which all the book-keeping for that program is done. In multitasking operating systems such as UNIX or Linux, new processes can be created by active processes. Such processes are parent processes while those created are child processes. It is common in programming for a parent process to delegate some work to a child process it creates while it may remain busy with something else. When the child is done executing, it will exit by calling the "exit" system call. This system call facilitates passing a small number back to the parent, which can retrieve this value using the "wait" system call. This is the exit status of the child. (A child may also exit by returning a value from the main function; this has the same effect.)

emantics

The parent and the child can have an understanding about the meaning of the exit statuses. For example, it is common programming practice for a child process to return zero to the parent signifying success. Apart from this return value from the child, other information like how the process exited, either normally or by a signal is also available to the parent process.

The specific set of codes returned is unique to the program that sets it. Typically it indicates success or failure. The value of the code returned by the function or program may indicate a specific cause of failure. On many systems, the higher the value, the more severe the cause of the error [cite web|url=http://www.robvanderwoude.com/errorlevel.html|title=Errorlevels|publisher=Rob van der Woude's Scripting Pages|accessdate=2007-08-26] . Alternatively, each bit may indicate a different condition, which are then xored together to give the final value; for example, fsck does this.

C

The C programming language requires only that programs exiting or returning from the main function be able to signal success or failure, using the macros EXIT_SUCCESS and EXIT_FAILURE; on Unix-like systems these evaluate to 0 and 1 respectively. [http://www.gnu.org/software/libc/manual/html_node/Exit-Status.html The GNU C Library Reference Manual 25.6.2: Exit Status] ] A fully portable C program cannot depend on any other value being available.

Java

In Java, any method can call System.exit(int status), unless a security manager does not permit this. This will terminate the currently running Java Virtual Machine. "The argument serves as a status code; by convention, a nonzero status code indicates abnormal termination." [cite web|url=http://java.sun.com/javase/6/docs/api/java/lang/System.html#exit(int)|title=Java 1.6.0 API|publisher=Sun|accessdate=2008-05-06] (int status is the errorlevel.)

Unix

On Unix, the wait system call sets a "status" value of type int packed as a bitfield with various types of child termination information. 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 lower 8 bits of the status value contain the exit status; [man|sh|wait|SUS] this can be retrieved using the WEXITSTATUS macro in wait.h. [man|bd|sys/wait.h|SUS] As such, on Unix exit statuses are restricted to values 0-255, the range of an unsigned 8-bit integer.

Unix like systems typically use a convention of zero for success and non zero for error. [http://www.faqs.org/docs/abs/HTML/exit-status.html] 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, and FreeBSD have documented an extensive set of preferred interpretations. [man|3|sysexits|FreeBSD|preferable exit codes for programs]

DOS

In DOS terminology, an errorlevel is an integer exit code returned by an executable program or subroutine. Errorlevels typically range from 0 to 255. In DOS there are only 255 error codes available.

DOS started to support "exit /B errorcode". However, some programmers reported that it was not working properly on some systems (e.g. Windows XP Professional). [cite web|url=http://jira.codehaus.org/browse/CONTINUUM-413|title=build reported as successful on win xp even when maven 1 build fails|publisher=Codehaus|accessdate=2007-08-26]

References

ee also

*Return statement


Wikimedia Foundation. 2010.

Игры ⚽ Поможем сделать НИР

Look at other dictionaries:

  • Exit — команда многих командных оболочек операционных систем и языков программирования, вызывающая завершение работы программы или командного интерпретатора с состоянием выхода (англ. exit status), равным указанному параметру n. Если параметр n опущен,… …   Википедия

  • Exit (command) — exit is a command used in many operating system command line shells. Entering the command logs the user out of their current session, or closes the user s current console or terminal connection.References*man|cu|exit|SUS|cause the shell to exit… …   Wikipedia

  • exit — команда многих командных оболочек операционных систем и языков программирования, вызывающая завершение работы программы или командного интерпретатора с состоянием выхода (англ. exit status), равным указанному параметру n. Если параметр n… …   Википедия

  • Exit (operating system) — A computer process terminates its execution by making an exit system call. More generally, an exit in a multithreading environment means that a thread of execution has stopped running. The operating system reclaims resources (memory, files, etc.) …   Wikipedia

  • Exit Tax — Ein Real Estate Investment Trust (REIT, deutsch: Immobilien Aktiengesellschaften mit börsennotierten Anteilen) ist eine Kapitalgesellschaft, deren Hauptgeschäftsfeld darin besteht, Immobilien zu besitzen und/oder zu verwalten. Auch Gesellschaften …   Deutsch Wikipedia

  • Exit Mundi — Infobox Website name = Exit Mundi caption = url = [http://www.exitmundi.nl/ Exit Mundi] commercial = type = Collection of End of World Scenarios language = English registration = Optional (required for forum) owner = Maarten Keulemans author =… …   Wikipedia

  • Exit Glacier — Infobox Glacier | glacier name = Exit Glacier caption = Exit Glacier type = Valley glacier location = Kenai Peninsula Borough, Alaska, U.S. coordinates = coord|60|10|42.18|N|149|38|57.98|W|type:glacier area = 4 miles (6.4 km) length = thickness …   Wikipedia

  • Exit & Entry Permit (Taiwan) — An Exit Entry Permit (Traditional Chinese: 中華民國台灣地區入出境許可證, more commonly known as 台證 or 入台證) is a document issued by the Immigration Office of the National Police Agency of the Republic of China, for Hong Kong and Macau residents holding PRC… …   Wikipedia

  • Status of Forces Agreement — A Status of Forces Agreement (SOFA) is an agreement between a country and a foreign nation stationing military forces in that country. AgreementsWhile the United States military has the largest foreign presence and therefore accounts for most… …   Wikipedia

  • Exit Wounds (Torchwood) — Doctorwhobox number = 26 serial name = Exit Wounds caption = Jack and Gwen mourn for Tosh, who bled to death. show = TW type = episode cast = * John Barrowman – Captain Jack Harkness * Eve Myles – Gwen Cooper * Burn Gorman – Owen Harper * Naoko… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”