193:
For the shell'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
121:
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
129:
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.
393:, 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).
98:. 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
504:
POSIX-compatible systems typically use a convention of zero for success and nonzero for error. 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.
381:, unless a security manager does not permit it. 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."
197:
If a command is not found, the shell should return a status of 127. If a command is found but is not executable, the return status should be 126. Note that this is not the case for all shells.
145:
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.
269:, 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).
819:, 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
194:
is terminated by a signal whose number is N, a shell sets the variable $ ? to a value greater than 128. Most shells use 128+N, while ksh93 uses 256+N.
1083:
878:
779:
509:
508:
BSD-derived OS's have defined an extensive set of preferred interpretations: Meanings for 15 status codes 64 through 78 are defined in
497:
system call (added with SUSv1), the child exit status and other information are no longer in a bitfield but in the structure of type
20:
719:
436:
683:
743:
726:(NB. BATTIPS.TXT is part of MPDOSTIP.ZIP. The provided link points to a HTML-converted older version of the BATTIPS.TXT file.)
523:
The
Advanced Bash-Scripting Guide and /usr/include/sysexits.h have some information on the meaning of non-0 exit status codes.
972:
836:
824:
727:
625:
107:. This system call facilitates passing the exit status code back to the parent, which can retrieve this value using the
775:
NWDOS-TIPs — Tips & Tricks rund um Novell DOS 7, mit Blick auf undokumentierte
Details, Bugs und Workarounds
1063:
1103:
474:
with various types of child termination information. If the child terminated by exiting (as determined by the
366:
200:
If a command fails because of an error during expansion or redirection, the exit status is greater than zero.
1129:
904:
325:
358:
339:
927:
854:
486:
specifies that the low-order 8 bits of the exit status can be retrieved from the status value using the
950:
652:
1039:
Google search for «"sysexits.h" site:github.com» reports «About 3,540 results»; retrieved 2013-02-21.
956:
933:
910:
584:
534:
uses 32-bit unsigned integers as exit codes, although the command interpreter treats them as signed.
483:
806:
710:
82:
in which the book-keeping for that program is maintained. In multitasking operating systems such as
1018:
882:
538:
217:
209:
108:
773:
90:, new processes can be created by active processes. The process that spawns another is called a
717:
715:
517:
26:"Result code" and "return code" redirect here. For the result code of software in general, see
227:. On Unix-like systems these are equal to 0 and 1 respectively. A C program may also use the
19:"Exit code" redirects here. For the prefix used to place an international telephone call, see
739:
347:
8:
677:
369:
to test the load status and return code of device drivers and the exit code of programs.
794:
698:
554:
479:
431:
318:
123:
99:
996:
747:
531:
858:
579:
406:
79:
71:
52:
537:
Exit codes are directly referenced, for example, by the command line interpreter
75:
840:
353:
which gets automatically updated on return from applications. COMMAND.COM under
976:
960:
937:
914:
629:
604:
550:
429:, the parent process can retrieve the exit status of a child process using the
362:
56:
1049:
1123:
723:
343:
231:
function specifying the integer status or exit macro as the first parameter.
213:
130:
Alternatively, each bit may indicate a different condition, with these being
816:
812:
350:
187:
16:
Integer number that is made available to the parent of a terminated process
354:
314:
104:
574:
335:
306:
302:
294:
290:
216:
to signal success or failure by returning an integer, or returning the
131:
27:
451:
calls retrieve only the least significant 8 bits of the exit status.
410:
36:
1028:
513:
471:
212:
programming language allows programs exiting or returning from the
401:
In Plan 9's C, exit status is indicated by a string passed to the
1024:
679:
478:
macro; the usual alternative being that it died from an uncaught
390:
282:
158:
154:
426:
87:
21:
International direct dialing § International call prefix
190:
typically execute commands and capture their exit statuses.
422:
310:
286:
162:
139:
83:
1023:: preferable exit codes for programs –
546:
298:
60:
653:"The GNU C Library Reference Manual 25.6.2: Exit Status"
520:, but they have since found use in many other programs.
250:
may translate it to "an implementation defined form" of
365:. In CONFIG.SYS, DR DOS 6.0 and higher supports
767:
765:
763:
761:
759:
757:
671:
669:
626:"Shell command language - Exit Status for commands"
443:call retrieves the full exit status, but the older
55:is an integer number that is made available to its
1076:
305:and higher support 16-bit error codes at least in
754:
731:
1121:
666:
297:. Errorlevels typically range from 0 to 255. In
1042:
138:together to give the final value; for example,
301:there are only 256 error codes available, but
811:(NB. NWDOSTIP.TXT is a comprehensive work on
618:
126:may also be available to the parent process.
1096:
737:
1056:
989:
955: – System Interfaces Reference,
932: – System Interfaces Reference,
896:
317:, exit codes (in batchjobs) can be set by
965:
919:
909: – Base Definitions Reference,
828:
597:
70:When computer programs are executed, the
1033:
879:"OpenVMS Format of Return Status Values"
778:. Release 157 (in German) (3 ed.).
122:process exited, either normally or by a
1010:
942:
647:
645:
1122:
1104:"ExitCodes bigger than 255, possible?"
871:
834:
682:(in German). 7: ERRORLEVEL abfragen.
607:. Rob van der Woude's Scripting Pages
881:. H71000.www7.hp.com. Archived from
771:
675:
642:
334:Exit statuses are often captured by
182:
847:
13:
1050:"Exit Codes with Special Meanings"
435:family of system calls defined in
14:
1141:
997:"Chapter 6. Exit and Exit Status"
772:Paul, Matthias R. (1997-07-30) .
676:Paul, Matthias R. (1997-05-01) .
512:. These historically derive from
242:function, which for values zero,
63:, this may be referred to as an
782:from the original on 2016-11-04
738:Auer, Eric; Paul, Matthias R.;
686:from the original on 2017-08-23
261:Apart from zero and the macros
837:"Windows 95/98/ME ERRORLEVELs"
835:Allen, William; Allen, Linda.
357:and higher supports a similar
1:
1084:"GetExitCodeProcess function"
957:The Single UNIX Specification
934:The Single UNIX Specification
911:The Single UNIX Specification
590:
377:In Java, any method can call
203:
324:and (in CONFIG.SYS) through
116:
7:
568:
545:terminology inherited from
359:pseudo-environment variable
165:, four levels are defined:
10:
1146:
526:
384:
148:
94:, while those created are
25:
18:
585:true and false (commands)
396:
427:POSIX-compatible systems
416:
256:unsuccessful termination
518:message transfer agents
379:System.exit(int status)
372:
277:In DOS terminology, an
1064:"ExitProcess function"
973:"2.4.3 Signal Actions"
361:%ERRORLVL% as well as
272:
252:successful termination
234:The return value from
744:"MS-DOS errorlevels"
348:environment variable
346:supports a reserved
1130:Process (computing)
557:refer to it as the
1027:Library Functions
555:Windows PowerShell
553:processes and the
291:executable program
51:) of a terminated
959:, Version 4 from
936:, Version 4 from
913:, Version 4 from
532:Microsoft Windows
462:interfaces set a
439:. Of these, the
238:is passed to the
183:Shell and scripts
132:evaluated by the
59:(or caller). In
1137:
1114:
1113:
1111:
1110:
1100:
1094:
1093:
1091:
1090:
1080:
1074:
1073:
1071:
1070:
1060:
1054:
1053:
1046:
1040:
1037:
1031:
1022:
1021:
1014:
1008:
1007:
1005:
1004:
993:
987:
986:
984:
983:
969:
963:
954:
953:
946:
940:
931:
930:
923:
917:
908:
907:
900:
894:
893:
891:
890:
875:
869:
868:
866:
865:
859:Sun Microsystems
855:"Java 1.6.0 API"
851:
845:
844:
839:. Archived from
832:
826:
822:
810:
804:
800:
798:
790:
788:
787:
769:
752:
751:
746:. Archived from
735:
729:
714:
708:
704:
702:
694:
692:
691:
673:
664:
663:
661:
660:
649:
640:
639:
637:
636:
622:
616:
615:
613:
612:
601:
580:Return statement
564:
561:property of the
560:
544:
500:
496:
489:
477:
469:
461:
457:
450:
446:
442:
434:
380:
268:
264:
249:
245:
241:
237:
230:
226:
222:
72:operating system
1145:
1144:
1140:
1139:
1138:
1136:
1135:
1134:
1120:
1119:
1118:
1117:
1108:
1106:
1102:
1101:
1097:
1088:
1086:
1082:
1081:
1077:
1068:
1066:
1062:
1061:
1057:
1048:
1047:
1043:
1038:
1034:
1017:
1016:
1015:
1011:
1002:
1000:
995:
994:
990:
981:
979:
971:
970:
966:
949:
948:
947:
943:
926:
925:
924:
920:
903:
902:
901:
897:
888:
886:
877:
876:
872:
863:
861:
853:
852:
848:
833:
829:
820:
802:
801:
792:
791:
785:
783:
770:
755:
742:(2015-12-24) .
736:
732:
706:
705:
696:
695:
689:
687:
674:
667:
658:
656:
651:
650:
643:
634:
632:
624:
623:
619:
610:
608:
603:
602:
598:
593:
571:
562:
558:
542:
529:
498:
494:
487:
475:
467:
459:
455:
448:
444:
440:
430:
419:
399:
387:
378:
375:
303:DR DOS 6.0
289:returned by an
275:
266:
262:
247:
243:
239:
235:
228:
224:
220:
206:
185:
151:
119:
96:child processes
76:abstract entity
31:
24:
17:
12:
11:
5:
1143:
1133:
1132:
1116:
1115:
1095:
1075:
1055:
1041:
1032:
1009:
988:
977:The Open Group
964:
961:The Open Group
941:
938:The Open Group
918:
915:The Open Group
895:
870:
846:
843:on 2011-07-07.
827:
753:
750:on 2015-12-24.
730:
722:2017-09-11 at
665:
641:
630:The Open Group
617:
595:
594:
592:
589:
588:
587:
582:
577:
570:
567:
551:.NET Framework
528:
525:
466:value of type
418:
415:
405:function, and
398:
395:
386:
383:
374:
371:
336:batch programs
274:
271:
205:
202:
184:
181:
180:
179:
176:
173:
170:
150:
147:
118:
115:
92:parent process
57:parent process
15:
9:
6:
4:
3:
2:
1142:
1131:
1128:
1127:
1125:
1105:
1099:
1085:
1079:
1065:
1059:
1051:
1045:
1036:
1030:
1026:
1020:
1013:
998:
992:
978:
974:
968:
962:
958:
952:
945:
939:
935:
929:
922:
916:
912:
906:
899:
885:on 2012-03-19
884:
880:
874:
860:
856:
850:
842:
838:
831:
825:
823:collection.)
818:
814:
808:
796:
781:
777:
776:
768:
766:
764:
762:
760:
758:
749:
745:
741:
734:
728:
725:
724:archive.today
721:
718:
716:
712:
700:
685:
681:
680:
672:
670:
654:
648:
646:
631:
627:
621:
606:
605:"Errorlevels"
600:
596:
586:
583:
581:
578:
576:
573:
572:
566:
556:
552:
548:
540:
535:
533:
524:
521:
519:
515:
511:
506:
502:
491:
488:WEXITSTATUS()
485:
481:
473:
465:
452:
438:
433:
428:
424:
414:
412:
408:
407:function main
404:
394:
392:
382:
370:
368:
364:
360:
356:
352:
349:
345:
344:Multiuser DOS
341:
340:IF ERRORLEVEL
337:
332:
330:
329:
323:
322:
316:
312:
308:
304:
300:
296:
292:
288:
284:
280:
270:
259:
257:
253:
232:
219:
215:
214:main function
211:
201:
198:
195:
191:
189:
188:Shell scripts
177:
174:
171:
168:
167:
166:
164:
160:
156:
146:
143:
141:
137:
135:
127:
125:
114:
113:system call.
112:
111:
106:
103:
102:
97:
93:
89:
85:
81:
77:
73:
68:
66:
62:
58:
54:
50:
46:
42:
38:
33:
29:
22:
1107:. Retrieved
1098:
1087:. Retrieved
1078:
1067:. Retrieved
1058:
1044:
1035:
1012:
1001:. Retrieved
991:
980:. Retrieved
967:
944:
921:
898:
887:. Retrieved
883:the original
873:
862:. Retrieved
849:
841:the original
830:
821:MPDOSTIP.ZIP
817:OpenDOS 7.01
813:Novell DOS 7
784:. Retrieved
774:
748:the original
733:
688:. Retrieved
678:
657:. Retrieved
633:. Retrieved
620:
609:. Retrieved
599:
536:
530:
522:
507:
503:
492:
470:packed as a
463:
453:
420:
402:
400:
388:
376:
363:%ERRORLEVEL%
333:
327:
320:
278:
276:
267:EXIT_FAILURE
263:EXIT_SUCCESS
260:
255:
251:
248:EXIT_FAILURE
244:EXIT_SUCCESS
233:
225:EXIT_FAILURE
221:EXIT_SUCCESS
207:
199:
196:
192:
186:
152:
144:
133:
128:
120:
109:
100:
95:
91:
69:
64:
48:
44:
40:
34:
32:
1019:sysexits(3)
803:|work=
707:|work=
476:WIFEXITED()
355:DR-DOS 7.02
315:COMMAND.COM
313:and DR-DOS
142:does this.
105:system call
74:creates an
41:exit status
1109:2009-09-28
1089:2022-04-22
1069:2016-12-16
1003:2012-07-09
999:. Faqs.org
982:2019-02-08
905:sys_wait.h
889:2012-07-09
864:2008-05-06
786:2014-08-06
690:2017-08-23
659:2012-07-09
635:2015-07-07
611:2007-08-26
591:References
575:Error code
543:errorlevel
516:and other
510:sysexits.h
425:and other
351:%ERRORLVL%
342:commands.
307:CONFIG.SYS
295:subroutine
279:errorlevel
204:C language
178:FAILURE 20
65:errorlevel
49:exit value
28:error code
805:ignored (
795:cite book
740:Hall, Jim
709:ignored (
699:cite book
655:. Gnu.org
499:siginfo_t
460:waitpid()
449:waitpid()
411:type void
117:Semantics
78:called a
45:exit code
37:computing
1124:Category
780:Archived
720:Archived
684:Archived
569:See also
565:object.
559:ExitCode
514:sendmail
495:waitid()
472:bitfield
441:waitid()
338:through
175:ERROR 10
136:operator
1025:FreeBSD
563:Process
541:in the
539:CMD.exe
527:Windows
493:In the
490:macro.
391:OpenVMS
385:OpenVMS
367:ONERROR
309:. With
283:integer
159:MorphOS
155:AmigaOS
149:AmigaOS
80:process
53:process
1029:Manual
928:waitid
549:. The
480:signal
464:status
456:wait()
445:wait()
437:wait.h
432:wait()
397:Plan 9
326:ERROR=
281:is an
229:exit()
218:macros
172:WARN 5
124:signal
43:(also
39:, the
417:POSIX
403:exits
319:EXIT
285:exit
88:Linux
951:wait
815:and
807:help
711:help
458:and
454:The
447:and
423:Unix
373:Java
311:4DOS
287:code
265:and
240:exit
236:main
223:and
208:The
169:OK 0
163:AROS
161:and
140:fsck
110:wait
101:exit
84:Unix
547:DOS
484:SUS
482:),
468:int
421:In
409:is
389:In
299:DOS
293:or
273:DOS
254:or
246:or
153:In
86:or
61:DOS
47:or
35:In
1126::
975:.
857:.
799::
797:}}
793:{{
756:^
703::
701:}}
697:{{
668:^
644:^
628:.
501:.
413:.
331:.
258:.
157:,
134:or
67:.
1112:.
1092:.
1072:.
1052:.
1006:.
985:.
892:.
867:.
809:)
789:.
713:)
693:.
662:.
638:.
614:.
328:n
321:n
210:C
30:.
23:.
Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.