1EXIT_SUCCESS(3const) EXIT_SUCCESS(3const)
2
3
4
6 EXIT_SUCCESS, EXIT_FAILURE - termination status constants
7
9 Standard C library (libc)
10
12 #include <stdlib.h>
13
14 #define EXIT_SUCCESS 0
15 #define EXIT_FAILURE /* nonzero */
16
18 EXIT_SUCCESS and EXIT_FAILURE represent a successful and unsuccessful
19 exit status respectively, and can be used as arguments to the exit(3)
20 function.
21
23 C99 and later; POSIX.1-2001 and later.
24
26 #include <stdio.h>
27 #include <stdlib.h>
28
29 int
30 main(int argc, char *argv[])
31 {
32 FILE *fp;
33
34 if (argc != 2) {
35 fprintf(stderr, "Usage: %s <file>\n", argv[0]);
36 exit(EXIT_FAILURE);
37 }
38
39 fp = fopen(argv[1], "r");
40 if (fp == NULL) {
41 perror(argv[1]);
42 exit(EXIT_FAILURE);
43 }
44
45 /* Other code omitted */
46
47 fclose(fp);
48 exit(EXIT_SUCCESS);
49 }
50
52 exit(3), sysexits.h(3head)
53
54
55
56Linux man-pages 6.05 2023-05-03 EXIT_SUCCESS(3const)