Overview
In computing, an exit operation ends the execution of a running task or program. On many modern computer systems this is performed by invoking a kernel-level system call conventionally called exit, which informs the operating system that the invoking process has finished. Termination can be normal (the program completed its work) or abnormal (terminated by a signal, exception, or explicit kill request).
Semantics and typical behavior
When a process invokes an exit call the kernel carries out cleanup steps: it closes open file descriptors, reclaims address space and memory, releases kernel objects, and updates process tables. Higher-level runtime libraries may perform additional actions before the kernel reclaims resources: for example, C's exit() calls registered atexit handlers and flushes stdio buffers. Lower-level variants (commonly named _exit or _Exit) request immediate kernel-level termination without invoking user-level cleanup routines.
Exit status, parent notification and zombies
A terminating process supplies an exit status, typically an integer where zero conventionally indicates success and nonzero values signal errors. On POSIX systems the parent is notified (the kernel delivers SIGCHLD) and can collect the child's status with wait-family calls. Until the parent collects this status the kernel preserves a small record for the terminated process; such a record is commonly called a "zombie". Once the parent performs wait or waitpid the kernel removes the final bookkeeping entry and fully reclaims the process slot.
Threads versus process exit
In a multithreading environment a distinction exists between thread exit and process exit. A thread-level exit (for example pthread_exit on POSIX) terminates only the calling thread and leaves the process and other threads running. A process-level exit ends all threads in the address space and triggers the global cleanup described above. Care is required when mixing thread libraries and process-level termination to avoid resource leaks or inconsistent program state.
Standards, platform variants and best practices
The basic notion of an exit call dates to early Unix design; POSIX standardized many aspects such as exit status semantics, SIGCHLD delivery, and the behavior of wait APIs. Other operating systems offer analogous mechanisms under different names (for example, some platforms expose functions like ExitProcess), but the core ideas — report an outcome, release resources, and allow parents or supervisors to observe termination — are common.
- Use appropriate exit variants when programs must run destructors or flush buffers versus when immediate termination is required.
- Be aware that external resources (network locks, mounted volumes, remote services) may not be reclaimed automatically and often require explicit cleanup before exit.
- Long-running services should handle child reaping or use process supervisors to avoid accumulating zombies.
For further information consult general operating system references and platform documentation about process control, the role of the kernel in cleanup, and thread APIs. See material on task and task and process management models for practical examples and on implementation notes in POSIX and platform manuals for exit-related functions and guarantees found in many computer and runtime environments.