EXIT_SUCCESS(3const)

EXIT_SUCCESS3const

Termination status constants

Usage

#include <stdlib.h>

#define EXIT_SUCCESS 0 #define EXIT_FAILURE /* nonzero */

Library

Standard C library (libc)

Overview

EXIT_SUCCESS and EXIT_FAILURE represent a successful and unsuccessful exit status respectively, and can be used as arguments to the exit(3) function.

Examples

#include <stdio.h>
#include <stdlib.h>
int
main(int argc, char *argv[])
{
    FILE *fp;
    if (argc != 2) {
        fprintf(stderr, "Usage: %s <file>\n", argv[0]);
        exit(EXIT_FAILURE);
    }
    fp = fopen(argv[1], "r");
    if (fp == NULL) {
        perror(argv[1]);
        exit(EXIT_FAILURE);
    }
    /* Other code omitted */
    fclose(fp);
    exit(EXIT_SUCCESS);
}

Releases

3 releases since Debian 12 (Bookworm); the text changed 2 times.

  1. 12
  2. 13
  3. Arch

Standards

C11, POSIX.1-2024.

History

EXIT_SUCCESS

C89, POSIX.1-1988.

EXIT_FAILURE

C89, POSIX.1-1990.

From man-pages 6.19-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.