<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.sarg.dev/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=2605%3A8D80%3A1395%3A18AF%3AC01%3A9946%3A449F%3A5185</id>
	<title>Vero - Wikipedia - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.sarg.dev/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=2605%3A8D80%3A1395%3A18AF%3AC01%3A9946%3A449F%3A5185"/>
	<link rel="alternate" type="text/html" href="https://wiki.sarg.dev/index.php/Special:Contributions/2605:8D80:1395:18AF:C01:9946:449F:5185"/>
	<updated>2026-08-14T15:42:27Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.44.2</generator>
	<entry>
		<id>https://wiki.sarg.dev/index.php?title=Exit_status&amp;diff=650401</id>
		<title>Exit status</title>
		<link rel="alternate" type="text/html" href="https://wiki.sarg.dev/index.php?title=Exit_status&amp;diff=650401"/>
		<updated>2025-11-01T00:03:12Z</updated>

		<summary type="html">&lt;p&gt;2605:8D80:1395:18AF:C01:9946:449F:5185: /* POSIX */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Short description|Integer number that is made available to the parent of a terminated process}}&lt;br /&gt;
{{Redirect|Exit code|the prefix used to place an international telephone call|International direct dialing#International call prefix}}&lt;br /&gt;
{{Redirect2|Result code|return code|the result code of software in general|error code}}&lt;br /&gt;
{{Use dmy dates|date=January 2022|cs1-dates=y}}&lt;br /&gt;
{{Use list-defined references|date=January 2022}}&lt;br /&gt;
&lt;br /&gt;
In [[computing]], the &#039;&#039;&#039;exit status&#039;&#039;&#039; (also &#039;&#039;&#039;exit code&#039;&#039;&#039; or &#039;&#039;&#039;exit value&#039;&#039;&#039;) of a terminated [[computer process|process]] is an integer number that is made available to its [[parent process]] (or caller).  In [[DOS]], this may be referred to as an &#039;&#039;&#039;errorlevel&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
When computer programs are executed, the [[operating system]] creates an [[abstract entity]] called a [[computer process|process]] in which the book-keeping for that program is maintained. In multitasking operating systems such as [[Unix]] or [[Linux]], new processes can be created by active processes. The process that spawns another is called a &#039;&#039;parent process&#039;&#039;, while those created are &#039;&#039;child processes&#039;&#039;.  Child processes run concurrently with the parent process. 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.  When the child finishes executing, it exits by calling the [[exit (system call)|&#039;&#039;exit&#039;&#039;]] [[system call]].  This system call facilitates passing the exit status code back to the parent, which can retrieve this value using the [[wait (operating system)|&#039;&#039;wait&#039;&#039;]] system call.&lt;br /&gt;
&lt;br /&gt;
==Semantics==&lt;br /&gt;
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 (exit with) 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 (computing)|signal]] may also be available to the parent process.&lt;br /&gt;
&lt;br /&gt;
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.&amp;lt;ref name=&amp;quot;Woude_2007&amp;quot;/&amp;gt; Alternatively, each bit may indicate a different condition, with these being [[Or (logic)|evaluated by the &#039;&#039;or&#039;&#039; operator]] together to give the final value; for example, [[fsck]] does this.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
===AmigaOS===&lt;br /&gt;
In [[AmigaOS]], [[MorphOS]] and [[AROS]], four levels are defined:&lt;br /&gt;
# {{mono|OK 0}}&lt;br /&gt;
# {{mono|WARN 5}}&lt;br /&gt;
# {{mono|ERROR 10}}&lt;br /&gt;
# {{mono|FAILURE 20}}&lt;br /&gt;
&lt;br /&gt;
===Shell and scripts===&lt;br /&gt;
[[Shell script]]s typically execute commands and capture their exit statuses.&lt;br /&gt;
&lt;br /&gt;
For the shell&#039;s purposes, a command which exits with a zero exit status has succeeded. A nonzero exit status indicates failure. 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. When a command is terminated by a signal whose number is {{code|N}}, a shell sets the variable {{code|$?}} to a value greater than 128. Most shells use {{mono|128+N}}, while ksh93 uses {{mono|256+N}}.&lt;br /&gt;
&lt;br /&gt;
If a command is not found, the shell should return a status of {{mono|127}}. If a command is found but is not executable, the return status should be {{mono|126}}.&amp;lt;ref name=&amp;quot;OpenGroup_2015&amp;quot;/&amp;gt; Note that this is not the case for all shells.&lt;br /&gt;
&lt;br /&gt;
If a command fails because of an error during expansion or redirection, the exit status is greater than zero.&lt;br /&gt;
&lt;br /&gt;
===C language===&lt;br /&gt;
The [[C (programming language)|C]] programming language allows programs exiting or returning from the [[main function]] to signal success or failure by returning an integer, or returning the [[Macro (computer science)|macros]] &amp;lt;code&amp;gt;EXIT_SUCCESS&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;EXIT_FAILURE&amp;lt;/code&amp;gt;. On Unix-like systems these are equal to 0 and 1 respectively.&amp;lt;ref name=&amp;quot;glibc&amp;quot; /&amp;gt;  A C program may also use the &amp;lt;code&amp;gt;exit()&amp;lt;/code&amp;gt; function specifying the integer status or exit macro as the first parameter.&lt;br /&gt;
&lt;br /&gt;
The return value from &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; is passed to the &amp;lt;code&amp;gt;exit&amp;lt;/code&amp;gt; function, which for values zero, &amp;lt;code&amp;gt;EXIT_SUCCESS&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;EXIT_FAILURE&amp;lt;/code&amp;gt; may translate it to &amp;quot;an implementation defined form&amp;quot; of &#039;&#039;successful termination&#039;&#039; or &#039;&#039;unsuccessful termination&#039;&#039;.{{Citation needed|date=May 2023}}&lt;br /&gt;
&lt;br /&gt;
Apart from zero and the macros &amp;lt;code&amp;gt;EXIT_SUCCESS&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;EXIT_FAILURE&amp;lt;/code&amp;gt;, the C standard does not define the meaning of return codes. Rules for the use of return codes vary on different platforms (see the platform-specific sections).&lt;br /&gt;
&lt;br /&gt;
===DOS===&lt;br /&gt;
In DOS terminology, an &#039;&#039;&#039;errorlevel&#039;&#039;&#039; is an [[integer]] exit [[code]] returned by an [[executable|executable program]] or [[subroutine]]. Errorlevels typically range from {{mono|0}} to {{mono|255}}.&amp;lt;ref name=&amp;quot;Paul_1997_BATTIPS&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;FD_2003_Errorlevel&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;Paul_1997_NWDOSTIP&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;Allen_2005&amp;quot;/&amp;gt; In [[DOS]] there are only 256 error codes available, but [[DR&amp;amp;nbsp;DOS 6.0]] and higher support 16-bit error codes at least in {{mono|[[CONFIG.SYS]]}}.&amp;lt;ref name=&amp;quot;Paul_1997_NWDOSTIP&amp;quot;/&amp;gt; With [[4DOS]] and DR-DOS {{mono|[[COMMAND.COM]]}}, exit codes (in batchjobs) can be set by [[EXIT (DOS command)|{{mono|EXIT &#039;&#039;n&#039;&#039;}}]]&amp;lt;!-- MS-DOS/PC DOS COMMAND.COM does not support the optional parameter, just EXIT without any arguments --&amp;gt;&amp;lt;ref name=&amp;quot;Paul_1997_NWDOSTIP&amp;quot;/&amp;gt; and (in {{mono|CONFIG.SYS}}) through {{mono|[[ERROR (CONFIG.SYS directive)|ERROR=&#039;&#039;n&#039;&#039;]]}}&amp;lt;!-- and a number of other more specialized directives --&amp;gt;.&amp;lt;ref name=&amp;quot;Paul_1997_NWDOSTIP&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Exit statuses are often captured by [[batch file|batch programs]] through [[IF ERRORLEVEL (DOS command)|{{mono|IF ERRORLEVEL}}]] commands.&amp;lt;ref name=&amp;quot;Paul_1997_BATTIPS&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;Paul_1997_NWDOSTIP&amp;quot;/&amp;gt; [[Multiuser DOS]] supports a reserved &amp;lt;!-- true --&amp;gt;[[environment variable]] [[%ERRORLVL%]] which gets automatically updated on return from applications. {{mono|COMMAND.COM}} under [[DR-DOS 7.02]] and higher supports a similar [[pseudo-environment variable]] {{mono|%ERRORLVL%}} as well as {{mono|[[%ERRORLEVEL%]]}}.&amp;lt;!-- MS-DOS and PC DOS do not, only Windows does! --&amp;gt; In {{mono|CONFIG.SYS}}, DR&amp;amp;nbsp;DOS 6.0 and higher supports [[ONERROR (CONFIG.SYS directive)|{{mono|ONERROR}}]] to test the load status and return code of device drivers and the exit code of programs.&amp;lt;ref name=&amp;quot;Paul_1997_NWDOSTIP&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Java===&lt;br /&gt;
In Java, any method can call &amp;lt;code&amp;gt;System.exit(int status)&amp;lt;/code&amp;gt;, unless a security manager does not permit it. This will terminate the currently running Java Virtual Machine. &amp;quot;The argument serves as a status code; by convention, a nonzero status code indicates abnormal termination.&amp;quot;&amp;lt;ref name=&amp;quot;Java&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===OpenVMS===&lt;br /&gt;
In [[OpenVMS]], success is indicated by odd values and failure by even values. The value is a 32-bit integer with sub-fields: control bits, facility number, message number and severity. Severity values are divided between success (Success, Informational) and failure (Warning, Error, Fatal).&amp;lt;ref name=&amp;quot;OpenVMS&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Plan 9===&lt;br /&gt;
In Plan 9&#039;s C, exit status is indicated by a string passed to the {{mono|exits()}} function, and [[Entry point#C and C++|function {{mono|main()}}]] is [[Void type|type {{mono|void}}]].&lt;br /&gt;
&lt;br /&gt;
===POSIX===&lt;br /&gt;
In [[Unix]] and other [[POSIX|POSIX-compatible systems]], the parent process can retrieve the exit status of a child process using the &amp;lt;code&amp;gt;[[Wait (system call)|wait()]]&amp;lt;/code&amp;gt; family of system calls defined in [[C POSIX library|POSIX header]] {{code|&amp;lt;wait.h&amp;gt;}}.&amp;lt;ref name=&amp;quot;BD_syswait&amp;quot;/&amp;gt;  Of these, the &amp;lt;code&amp;gt;waitid()&amp;lt;/code&amp;gt;&amp;lt;ref name=&amp;quot;SH_waitid&amp;quot;/&amp;gt; call retrieves the full exit status, but the older &amp;lt;code&amp;gt;wait()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;waitpid()&amp;lt;/code&amp;gt;&amp;lt;ref name=&amp;quot;SH_wait&amp;quot;/&amp;gt; calls retrieve only the least significant 8 bits of the exit status.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;wait()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;waitpid()&amp;lt;/code&amp;gt; interfaces set a &#039;&#039;status&#039;&#039; value of type &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; packed as a [[bitfield]] with various types of child termination information.  If the child terminated by exiting (as determined by the &amp;lt;code&amp;gt;WIFEXITED()&amp;lt;/code&amp;gt; macro; the usual alternative being that it died from an uncaught [[signal (computing)|signal]]), [[Single UNIX Specification|SUS]] specifies that the low-order 8 bits of the exit status can be retrieved from the status value using the &amp;lt;code&amp;gt;WEXITSTATUS()&amp;lt;/code&amp;gt; macro.&lt;br /&gt;
&lt;br /&gt;
In the &amp;lt;code&amp;gt;waitid()&amp;lt;/code&amp;gt; system call (added with SUSv1), the child exit status and other information are no longer in a bitfield but in the structure of type &amp;lt;code&amp;gt;siginfo_t&amp;lt;/code&amp;gt;.&amp;lt;ref name=&amp;quot;OpenGroup&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
POSIX-compatible systems typically use a convention of zero for success and nonzero for error.&amp;lt;ref name=&amp;quot;ExitStatus&amp;quot;/&amp;gt;  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.&amp;lt;ref name=&amp;quot;glibc&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
BSD-derived OS&#039;s have defined an extensive set of preferred interpretations: Meanings for 15 status codes 64 through 78 are defined in POSIX header {{code|&amp;lt;sysexits.h&amp;gt;}}.&amp;lt;ref name=&amp;quot;FreeBSD&amp;quot;/&amp;gt; These historically derive from [[sendmail]] and other [[message transfer agent]]s, but they have since found use in many other programs.&amp;lt;ref name=&amp;quot;sysexits&amp;quot;/&amp;gt;  It has been deprecated and its use is discouraged.&amp;lt;ref name=&amp;quot;FreeBSD&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Advanced Bash-Scripting Guide has some information on the meaning of non-0 exit status codes.&amp;lt;ref name=&amp;quot;SpecialMeanings&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Windows===&lt;br /&gt;
[[Microsoft Windows]] uses 32-bit unsigned integers as exit codes,&amp;lt;ref name=&amp;quot;ExitProcess&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;GetExitCodeProcess&amp;quot; /&amp;gt; although the command interpreter treats them as signed.&amp;lt;ref name=&amp;quot;ExitCodesBig&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Exit codes are directly referenced, for example, by the command line interpreter [[Command Prompt (Windows)|CMD.exe]] in the &amp;lt;code&amp;gt;errorlevel&amp;lt;/code&amp;gt; terminology inherited from [[DOS]]. The [[.NET Framework]] processes and the [[Windows PowerShell]] refer to it as the &amp;lt;code&amp;gt;ExitCode&amp;lt;/code&amp;gt; property of the &amp;lt;code&amp;gt;Process&amp;lt;/code&amp;gt; object.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Error code]]&lt;br /&gt;
* [[Return statement]]&lt;br /&gt;
* [[true and false (commands)]]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist|refs=&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Paul_1997_NWDOSTIP&amp;quot;&amp;gt;{{cite book |title=NWDOS-TIPs&amp;amp;nbsp;— Tips &amp;amp; Tricks rund um Novell DOS 7, mit Blick auf undokumentierte Details, Bugs und Workarounds |work=MPDOSTIP |author-first=Matthias R. |author-last=Paul |date=1997-07-30 |orig-date=1994-05-01 |edition=3 |version=Release 157 |language=de |url=http://www.antonis.de/dos/dos-tuts/mpdostip/html/nwdostip.htm |access-date=2014-08-06 |url-status=live |archive-url=https://web.archive.org/web/20161104235829/http://www.antonis.de/dos/dos-tuts/mpdostip/html/nwdostip.htm |archive-date=2016-11-04}} (NB. NWDOSTIP.TXT is a comprehensive work on [[Novell DOS 7]] and [[OpenDOS 7.01]], including the description of many undocumented features and internals. The provided link points to a HTML-converted version of the file, which is part of the &amp;lt;code&amp;gt;MPDOSTIP.ZIP&amp;lt;/code&amp;gt;&amp;lt;!-- still named TIPS_MP.ZIP between 1991 and 1996-11 --&amp;gt; collection.) [https://web.archive.org/web/20190601152204/https://www.sac.sk/download/text/mpdostip.zip&amp;lt;!-- A yet older version 155 from 1997-05-13 of the 1997-07-15 distribution archive. --&amp;gt;]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Paul_1997_BATTIPS&amp;quot;&amp;gt;{{cite book |title=BATTIPs&amp;amp;nbsp;— Tips &amp;amp; Tricks zur Programmierung von Batchjobs |at=7: ERRORLEVEL abfragen |work=MPDOSTIP |author-first=Matthias R. |author-last=Paul |date=1997-05-01 |orig-date=1993-10-01 |language=de |url=http://www.antonis.de/dos/batchtut/battips/index.htm#7 |access-date=2017-08-23 |url-status=live |archive-url=https://web.archive.org/web/20170823191411/http://www.antonis.de/dos/batchtut/battips/index.htm |archive-date=2017-08-23 }} [https://www.auersoft.eu/soft/by-others/dos-exitcodes-de.html] [https://www.auersoft.eu/soft/by-others/dos-exitcodes-en.html] {{Webarchive|url=https://archive.today/20170911103337/https://www.auersoft.eu/soft/by-others/dos-exitcodes-en.html |date=2017-09-11  }} (NB. BATTIPS.TXT is part of MPDOSTIP.ZIP. The provided link points to a HTML-converted older version of the BATTIPS.TXT file.) [https://web.archive.org/web/20190601152204/https://www.sac.sk/download/text/mpdostip.zip&amp;lt;!-- A yet older version 155 from 1997-05-13 of the 1997-07-15 distribution archive. --&amp;gt;]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;FD_2003_Errorlevel&amp;quot;&amp;gt;{{cite web |title=MS-DOS errorlevels |author-first1=Eric |author-last1=Auer |author-first2=Matthias R. |author-last2=Paul |author-first3=Jim |author-last3=Hall |author-link3=Jim Hall (programmer) |date=2015-12-24 |orig-date=2003-12-31 |url=http://www.freedos.org/technotes/technote/207.html |url-status=dead |archive-url=https://web.archive.org/web/20151224202118/http://www.freedos.org/technotes/technote/207.html |archive-date=2015-12-24}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Allen_2005&amp;quot;&amp;gt;{{cite web |author-first1=William |author-last1=Allen |author-first2=Linda |author-last2=Allen |title=Windows 95/98/ME ERRORLEVELs |url=http://www.allenware.com/mcsw/errorlevels.zip |url-status=dead |archive-url=https://web.archive.org/web/20110707113138/http://www.allenware.com/mcsw/errorlevels.zip |archive-date=2011-07-07}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OpenGroup_2015&amp;quot;&amp;gt;{{cite web |title=Shell command language - Exit Status for commands |url=http://pubs.opengroup.org/onlinepubs/9699919799//utilities/V3_chap02.html#tag_18_08_02 |publisher=[[The Open Group]] |access-date=2015-07-07}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;glibc&amp;quot;&amp;gt;{{cite web |url=https://www.gnu.org/software/libc/manual/html_node/Exit-Status.html |title=The GNU C Library Reference Manual 25.6.2: Exit Status |publisher=Gnu.org |access-date=2012-07-09}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Java&amp;quot;&amp;gt;{{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 Microsystems]] |access-date=2008-05-06}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OpenVMS&amp;quot;&amp;gt;{{cite web |url=http://h71000.www7.hp.com/commercial/c/docs/5492profile_016.html |title=OpenVMS Format of Return Status Values |publisher=H71000.www7.hp.com |access-date=2012-07-09 |archive-url=https://web.archive.org/web/20120319171215/http://h71000.www7.hp.com/commercial/c/docs/5492profile_016.html |archive-date=2012-03-19 |url-status=dead}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;BD_syswait&amp;quot;&amp;gt;{{man|bd|sys_wait.h|SUS}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;SH_waitid&amp;quot;&amp;gt;{{man|sh|waitid|SUS}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;SH_wait&amp;quot;&amp;gt;{{man|sh|wait|SUS}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OpenGroup&amp;quot;&amp;gt;{{cite web |url=http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_04_03_03 |title=2.4.3 Signal Actions |publisher=[[The Open Group]] |access-date=2019-02-08}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;ExitStatus&amp;quot;&amp;gt;{{cite web |url=http://www.faqs.org/docs/abs/HTML/exit-status.html |title=Chapter 6. Exit and Exit Status |publisher=Faqs.org |access-date=2012-07-09}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;FreeBSD&amp;quot;&amp;gt;{{man|3|sysexits|FreeBSD|preferable exit codes for programs}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;sysexits&amp;quot;&amp;gt;Google search for «&amp;quot;sysexits.h&amp;quot; site:github.com» reports «About 3,540 results»; retrieved 2013-02-21.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;SpecialMeanings&amp;quot;&amp;gt;{{cite web |url=http://tldp.org/LDP/abs/html/exitcodes.html |title=Exit Codes with Special Meanings}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;ExitProcess&amp;quot;&amp;gt;{{cite web |url=https://msdn.microsoft.com/en-us/library/windows/desktop/ms682658(v=vs.85).aspx |title=ExitProcess function |access-date=2016-12-16}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;GetExitCodeProcess&amp;quot;&amp;gt;{{cite web |url=https://docs.microsoft.com/ja-jp/windows/win32/api/processthreadsapi/nf-processthreadsapi-getexitcodeprocess |title=GetExitCodeProcess function |access-date=2022-04-22}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;ExitCodesBig&amp;quot;&amp;gt;{{cite web |url=https://stackoverflow.com/questions/179565/exitcodes-bigger-than-255-possible |title=ExitCodes bigger than 255, possible? |access-date=2009-09-28}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Woude_2007&amp;quot;&amp;gt;{{cite web |url=http://www.robvanderwoude.com/errorlevel.php |title=Errorlevels |publisher=Rob van der Woude&#039;s Scripting Pages |access-date=2007-08-26}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{DEFAULTSORT:Exit Status}}&lt;br /&gt;
[[Category:Process (computing)]]&lt;/div&gt;</summary>
		<author><name>2605:8D80:1395:18AF:C01:9946:449F:5185</name></author>
	</entry>
	<entry>
		<id>https://wiki.sarg.dev/index.php?title=Return_type&amp;diff=337125</id>
		<title>Return type</title>
		<link rel="alternate" type="text/html" href="https://wiki.sarg.dev/index.php?title=Return_type&amp;diff=337125"/>
		<updated>2025-10-31T23:50:07Z</updated>

		<summary type="html">&lt;p&gt;2605:8D80:1395:18AF:C01:9946:449F:5185: typo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Short description|Type of data able to be returned by a function or method}}&lt;br /&gt;
&lt;br /&gt;
In [[computer programming]], the &#039;&#039;&#039;return type&#039;&#039;&#039; (or &#039;&#039;&#039;result type&#039;&#039;&#039;) defines and constrains the [[data type]] of the value [[Return statement|returned]] from a [[subroutine]] or [[Method (computer programming)|method]].&amp;lt;ref&amp;gt;{{cite book |last1=Kernighan |first1=Brian W. |author1-link=Brian Kernighan |last2=Ritchie |first2=Dennis M. |author2-link=Dennis Ritchie |title=[[The C Programming Language]] | edition=2nd |publisher=Prentice Hall |year=1988 |isbn=0-13-110362-8}}&amp;lt;/ref&amp;gt;  In many [[programming languages]] (especially [[statically-typed programming language]]s such as [[C (programming language)|C]], [[C++]], [[Java (programming language)|Java]]) the return type must be explicitly specified when declaring a function.&lt;br /&gt;
&lt;br /&gt;
In the C example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
int calculateSum(int a, int b) {&lt;br /&gt;
    return a + b;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
the return type is {{mono|[[Integer (computer science)|int]]}}. The program can therefore rely on the method returning a value of type {{mono|int}}. Various mechanisms are used for the case where a subroutine does not return any value, e.g., a return type of {{mono|[[Void type|void]]}} is used in some programming languages:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void sayHello() {&lt;br /&gt;
    printf(&amp;quot;Hello, world!&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Returning a value from a method==&lt;br /&gt;
&lt;br /&gt;
A method returns to the code that invoked it when it completes all the statements in the method, reaches a return statement, or&lt;br /&gt;
throws an exception, whichever occurs first.&lt;br /&gt;
&lt;br /&gt;
To declare a method&#039;s return type, it is included in its method declaration. Within the body of the method, the return statement is used to return the value.&lt;br /&gt;
&lt;br /&gt;
Any method declared void does not return a value. It does not need to contain a return statement, but it may do so. In such a case, a return statement can be used to branch out of a control flow block and exit the method and is simply used like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
return;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If a value from a method declared {{code|void}} is returned, a compiler error will occur.&lt;br /&gt;
&lt;br /&gt;
Any method that is not declared {{code|void}} must contain a return statement with a corresponding return value, like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
return returnValue;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The data type of the return value must match the method&#039;s declared return type; for instance, one cannot return an {{code|int}} value from a method declared to return a {{code|bool}}.&lt;br /&gt;
&lt;br /&gt;
The {{code|getArea()}} method in the {{code|Rectangle}} class that was discussed in the sections on objects returns an {{code|int}}:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
class Rectangle {&lt;br /&gt;
    private int width;&lt;br /&gt;
    private int height;&lt;br /&gt;
    // ...&lt;br /&gt;
&lt;br /&gt;
    // A method for computing the area of the rectangle&lt;br /&gt;
    public int getArea() {&lt;br /&gt;
        return width * height;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This method returns the integer that the expression {{code|width * height}} evaluates to.&lt;br /&gt;
&lt;br /&gt;
The {{code|getArea()}} method returns a primitive type. A method can also return a [[reference type]]. For example, in a program to manipulate {{code|Bicycle}} objects, we may have a method like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
class Bicycle {&lt;br /&gt;
    // bicycle class&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class RaceEnvironment {&lt;br /&gt;
    // environment class&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class BicycleRace {&lt;br /&gt;
    // ...&lt;br /&gt;
&lt;br /&gt;
    public Bicycle playBicycleRace(Bicycle bike1, Bicycle bike2, RaceEnvironment env) {&lt;br /&gt;
        Bicycle winner;&lt;br /&gt;
        // Code to calculate which bike is &lt;br /&gt;
        // faster, given each bike&#039;s gear &lt;br /&gt;
        // and cadence and given the &lt;br /&gt;
        // environment (terrain and wind)&lt;br /&gt;
        return winner;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{Reflist}} &lt;br /&gt;
&lt;br /&gt;
{{DEFAULTSORT:Return Type}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Subroutines]]&lt;br /&gt;
[[Category:Articles with example Java code]]&lt;/div&gt;</summary>
		<author><name>2605:8D80:1395:18AF:C01:9946:449F:5185</name></author>
	</entry>
</feed>