| 1 |
.\" Copyright 2022, Thomas Voss <[email protected]> |
| 2 |
.\" Copyright, the authors of the Linux man-pages project |
| 3 |
.\" |
| 4 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 5 |
.\" |
| 6 |
.\" |
| 7 |
.TH EXIT_SUCCESS 3const 2026-02-08 "Linux man-pages 6.18" |
| 8 |
.SH NAME |
| 9 |
EXIT_SUCCESS, EXIT_FAILURE \- termination status constants |
| 10 |
.SH LIBRARY |
| 11 |
Standard C library |
| 12 |
.RI ( libc ) |
| 13 |
.SH SYNOPSIS |
| 14 |
.nf |
| 15 |
.B #include <stdlib.h> |
| 16 |
.P |
| 17 |
.BR "#define EXIT_SUCCESS " 0 |
| 18 |
.BR "#define EXIT_FAILURE " "/* nonzero */" |
| 19 |
.fi |
| 20 |
.SH DESCRIPTION |
| 21 |
.B EXIT_SUCCESS |
| 22 |
and |
| 23 |
.B EXIT_FAILURE |
| 24 |
represent a successful and unsuccessful exit status respectively, |
| 25 |
and can be used as arguments to the |
| 26 |
.BR exit (3) |
| 27 |
function. |
| 28 |
.SH STANDARDS |
| 29 |
C11, POSIX.1-2024. |
| 30 |
.SH HISTORY |
| 31 |
.TP |
| 32 |
.B EXIT_SUCCESS |
| 33 |
C89, |
| 34 |
POSIX.1-1988. |
| 35 |
.TP |
| 36 |
.B EXIT_FAILURE |
| 37 |
C89, |
| 38 |
POSIX.1-1990. |
| 39 |
.SH EXAMPLES |
| 40 |
.\" SRC BEGIN (EXIT_SUCCESS.c) |
| 41 |
.EX |
| 42 |
#include <stdio.h> |
| 43 |
#include <stdlib.h> |
| 44 |
\& |
| 45 |
int |
| 46 |
main(int argc, char *argv[]) |
| 47 |
{ |
| 48 |
FILE *fp; |
| 49 |
\& |
| 50 |
if (argc != 2) { |
| 51 |
fprintf(stderr, "Usage: %s <file>\[rs]n", argv[0]); |
| 52 |
exit(EXIT_FAILURE); |
| 53 |
} |
| 54 |
\& |
| 55 |
fp = fopen(argv[1], "r"); |
| 56 |
if (fp == NULL) { |
| 57 |
perror(argv[1]); |
| 58 |
exit(EXIT_FAILURE); |
| 59 |
} |
| 60 |
\& |
| 61 |
/* Other code omitted */ |
| 62 |
\& |
| 63 |
fclose(fp); |
| 64 |
exit(EXIT_SUCCESS); |
| 65 |
} |
| 66 |
.EE |
| 67 |
.\" SRC END |
| 68 |
.SH SEE ALSO |
| 69 |
.BR exit (3), |
| 70 |
.BR sysexits.h (3head) |