_exit man page

_exit, _Exit — terminate the calling process

Synopsis

#include <unistd.h>

void _exit(int status);

#include <stdlib.h>

void _Exit(int status);

Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

_Exit():

_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L

Description

The function _exit() terminates the calling process "immediately". Any open file descriptors belonging to the process are closed; any children of the process are inherited by process 1, init, and the process's parent is sent a SIGCHLD signal.

The value status is returned to the parent process as the process's exit status, and can be collected using one of the wait(2) family of calls.

The function _Exit() is equivalent to _exit().

Return Value

These functions do not return.

Conforming to

POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD. The function _Exit() was introduced by C99.

Notes

For a discussion on the effects of an exit, the transmission of exit status, zombie processes, signals sent, and so on, see exit(3).

The function _exit() is like exit(3), but does not call any functions registered with atexit(3) or on_exit(3). Open stdio(3) streams are not flushed. On the other hand, _exit() does close open file descriptors, and this may cause an unknown delay, waiting for pending output to finish. If the delay is undesired, it may be useful to call functions like tcflush(3) before calling _exit(). Whether any pending I/O is canceled, and which pending I/O may be canceled upon _exit(), is implementation-dependent.

C library/kernel differences

In glibc up to version 2.3, the _exit() wrapper function invoked the kernel system call of the same name. Since glibc 2.3, the wrapper function invokes exit_group(2), in order to terminate all of the threads in a process.

See Also

execve(2), exit_group(2), fork(2), kill(2), wait(2), wait4(2), waitpid(2), atexit(3), exit(3), on_exit(3), termios(3)

Colophon

This page is part of release 4.08 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/.

Referenced By

atexit(3), clone(2), daemon(3), drmaa_wait(3), exit(3), exit_group(2), expect(1), explain_accept4_or_die(3), explain_accept_or_die(3), explain_acct_or_die(3), explain_acl_from_text_or_die(3), explain_acl_get_fd_or_die(3), explain_acl_get_file_or_die(3), explain_acl_set_fd_or_die(3), explain_acl_set_file_or_die(3), explain_acl_to_text_or_die(3), explain_adjtime_or_die(3), explain_adjtimex_or_die(3), explain_asprintf_or_die(3), explain_bind_or_die(3), explain_calloc_or_die(3), explain_chown_or_die(3), explain_chroot_or_die(3), explain_closedir_or_die(3), explain_close_or_die(3), explain_connect_or_die(3), explain_creat_or_die(3), explain_dirfd_or_die(3), explain_dup2_or_die(3), explain_dup_or_die(3), explain_endgrent_or_die(3), explain_eventfd_or_die(3), explain_execlp_or_die(3), explain_execve_or_die(3), explain_execv_or_die(3), explain_execvp_or_die(3), explain_fchdir_or_die(3), explain_fchmod_or_die(3), explain_fchownat_or_die(3), explain_fchown_or_die(3), explain_fcntl_or_die(3), explain_fdopendir_or_die(3), explain_fdopen_or_die(3), explain_feof_or_die(3), explain_ferror_or_die(3), explain_fflush_or_die(3), explain_fgetc_or_die(3), explain_fgetpos_or_die(3), explain_fgets_or_die(3), explain_fileno_or_die(3), explain_flock_or_die(3), explain_fopen_or_die(3), explain_fork_or_die(3), explain_fpathconf_or_die(3), explain_fprintf_or_die(3), explain_fpurge_or_die(3), explain_fputc_or_die(3), explain_fputs_or_die(3), explain_fread_or_die(3), explain_fseeko_or_die(3), explain_fseek_or_die(3), explain_fsetpos_or_die(3), explain_fstatat_or_die(3), explain_fstatfs_or_die(3), explain_fstat_or_die(3), explain_fstatvfs_or_die(3), explain_fsync_or_die(3), explain_ftello_or_die(3), explain_ftell_or_die(3), explain_ftime_or_die(3), explain_ftruncate_or_die(3), explain_futimens_or_die(3), explain_futimesat_or_die(3), explain_futimes_or_die(3), explain_fwrite_or_die(3), explain_getaddrinfo_or_die(3), explain_getchar_or_die(3), explain_getc_or_die(3), explain_getcwd_or_die(3), explain_getdomainname_or_die(3), explain_getgrent_or_die(3), explain_getgrouplist_or_die(3), explain_getgroups_or_die(3), explain_gethostbyname_or_die(3), explain_gethostid_or_die(3), explain_gethostname_or_die(3), explain_getpeername_or_die(3), explain_getpgid_or_die(3), explain_getpgrp_or_die(3), explain_getpriority_or_die(3), explain_getresgid_or_die(3), explain_getresuid_or_die(3), explain_getrlimit_or_die(3), explain_getrusage_or_die(3), explain_getsockname_or_die(3), explain_getsockopt_or_die(3), explain_gettimeofday_or_die(3), explain_getw_or_die(3), explain_iconv_close_or_die(3), explain_iconv_open_or_die(3), explain_iconv_or_die(3), explain_ioctl_or_die(3), explain_kill_or_die(3), explain_lca2010(1), explain_lchmod_or_die(3), explain_lchownat_or_die(3), explain_lchown_or_die(3), explain_linkat_or_die(3), explain_link_or_die(3), explain_listen_or_die(3), explain_lseek_or_die(3), explain_lstat_or_die(3), explain_lutimes_or_die(3), explain_malloc_or_die(3), explain_mkdir_or_die(3), explain_mkdtemp_or_die(3), explain_mknod_or_die(3), explain_mkostemp_or_die(3), explain_mkstemp_or_die(3), explain_mktemp_or_die(3), explain_mmap_or_die(3), explain_mount_or_die(3), explain_munmap_or_die(3), explain_nanosleep_or_die(3), explain_nice_or_die(3), explain_openat_or_die(3), explain_opendir_or_die(3), explain_output(3), explain_pathconf_or_die(3), explain_pclose_or_die(3), explain_pipe2_or_die(3), explain_pipe_or_die(3), explain_poll_or_die(3), explain_popen_or_die(3), explain_pread_or_die(3), explain_printf_or_die(3), explain_ptrace_or_die(3), explain_putchar_or_die(3), explain_putc_or_die(3), explain_putenv_or_die(3), explain_puts_or_die(3), explain_putw_or_die(3), explain_pwrite_or_die(3), explain_raise_or_die(3), explain_readdir_or_die(3), explain_readlink_or_die(3), explain_read_or_die(3), explain_readv_or_die(3), explain_realloc_or_die(3), explain_realpath_or_die(3), explain_remove_or_die(3), explain_rename_or_die(3), explain_rmdir_or_die(3), explain_select_or_die(3), explain_setbuffer_or_die(3), explain_setbuf_or_die(3), explain_setdomainname_or_die(3), explain_setenv_or_die(3), explain_setgid_or_die(3), explain_setgrent_or_die(3), explain_setgroups_or_die(3), explain_sethostname_or_die(3), explain_setlinebuf_or_die(3), explain_setpgid_or_die(3), explain_setpgrp_or_die(3), explain_setpriority_or_die(3), explain_setregid_or_die(3), explain_setresgid_or_die(3), explain_setresuid_or_die(3), explain_setreuid_or_die(3), explain_setsid_or_die(3), explain_setsockopt_or_die(3), explain_settimeofday_or_die(3), explain_setuid_or_die(3), explain_setvbuf_or_die(3), explain_shmat_or_die(3), explain_shmctl_or_die(3), explain_signalfd_or_die(3), explain_sleep_or_die(3), explain_snprintf_or_die(3), explain_socket_or_die(3), explain_socketpair_or_die(3), explain_sprintf_or_die(3), explain_statfs_or_die(3), explain_stat_or_die(3), explain_statvfs_or_die(3), explain_stime_or_die(3), explain_strcoll_or_die(3), explain_strdup_or_die(3), explain_strndup_or_die(3), explain_strtod_or_die(3), explain_strtof_or_die(3), explain_strtold_or_die(3), explain_strtoll_or_die(3), explain_strtol_or_die(3), explain_strtoull_or_die(3), explain_strtoul_or_die(3), explain_symlink_or_die(3), explain_system_or_die(3), explain_tcdrain_or_die(3), explain_tcflow_or_die(3), explain_tcflush_or_die(3), explain_tcgetattr_or_die(3), explain_tcsendbreak_or_die(3), explain_tcsetattr_or_die(3), explain_telldir_or_die(3), explain_tempnam_or_die(3), explain_time_or_die(3), explain_timerfd_create_or_die(3), explain_tmpfile_or_die(3), explain_tmpnam_or_die(3), explain_truncate_or_die(3), explain_uname_or_die(3), explain_ungetc_or_die(3), explain_unlink_or_die(3), explain_unsetenv_or_die(3), explain_usleep_or_die(3), explain_ustat_or_die(3), explain_utimensat_or_die(3), explain_utimens_or_die(3), explain_utime_or_die(3), explain_utimes_or_die(3), explain_vasprintf_or_die(3), explain_vfork_or_die(3), explain_vfprintf_or_die(3), explain_vprintf_or_die(3), explain_vsnprintf_or_die(3), explain_vsprintf_or_die(3), explain_wait3_or_die(3), explain_wait4_or_die(3), explain_wait_or_die(3), explain_waitpid_or_die(3), explain_write_or_die(3), explain_writev_or_die(3), fork(2), kill(2), on_exit(3), pagesend.8c(8), pmGetConfig(3), prctl(2), proc(5), ptrace(2), seccomp(2), setsid(2), shmop(2), socket(7), syscalls(2), system(3), systemd.service(5), vfork(2), wait(2).

exit(2) and _Exit(2) are aliases of _exit(2).

2016-03-15 Linux Linux Programmer's Manual