EXIT_SUCCESS(3const)

πŸ’– EXIT_SUCCESS β€” the const girlies of process termination πŸ’–

okay bestie, so this is EXIT_SUCCESS(3const) β€” a page from the <pink>3const</pink> corner of the manual, and honestly? it's giving tiny-but-mighty. two constants. that's the whole page. and yet they run the entire exit-code economy. periodt.


✨ NAME ✨

EXIT_SUCCESS, EXIT_FAILURE β€” termination status constants πŸŽ€

πŸ“š LIBRARY πŸ“š

Standard C library (libc) 🫢

🌸 SYNOPSIS 🌸

#include <stdlib.h>

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

like... look at that. EXIT_SUCCESS is literally just 0. no cap. and EXIT_FAILURE is <hotpink>/* nonzero */</hotpink> β€” the manpage is out here being coy about it, which is honestly iconic behaviour. πŸ¦‹

πŸ’… DESCRIPTION πŸ’…

so here's the vibe: EXIT_SUCCESS and EXIT_FAILURE represent a successful and unsuccessful exit status respectively. that's the whole personality. they're the two moods you can leave a program in.

and you can use them as arguments to the exit(3) function β€” that's their main character moment, that's their whole reason for existing, and they absolutely ate. πŸ‘‘

⭐ STANDARDS ⭐

C11, POSIX.1-2024 🧚

πŸ•°οΈ HISTORY πŸ•°οΈ

the lore, bestie:

  • EXIT_SUCCESS β€” C89, POSIX.1-1988 ✨
  • EXIT_FAILURE β€” C89, POSIX.1-1990 ✨
not the two of them having different POSIX years. EXIT_SUCCESS was out here first, fr fr. πŸ™ˆ

🌈 EXAMPLES 🌈

here's the whole thing in context, a cute lil program that opens a file and bails properly if anything goes sideways:

#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);
}

see how it goes? wrong number of args β†’ exit(EXIT_FAILURE). file won't open β†’ exit(EXIT_FAILURE). everything works β†’ fclose(fp) and then exit(EXIT_SUCCESS). sweet and simple, and the /* Other code omitted */ is doing a LOT of heavy lifting in there, love that for it. πŸ’€

πŸ‘€ SEE ALSO πŸ‘€


that's the page!! short, sweet, and lowkey the most-used constants in the whole C library. iykyk. πŸ’œ

with love from the Linux man-pages, version 6.20, dated 2026-02-08 β€” mwah, go exit cleanly bestie 🫢✨

πŸ“¦ where this page comes from
  • arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • πŸ“œ the page's license: Linux-man-pages-copyleft
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms