All the thread libraries that I know (for example, the latest glibc or musl-libc ) use the low-level clone (2) system call to implement their threads (and some C libraries even use the clone to fork process).
clone is a sophisticated Linux syscall. If you are not a streaming library developer, you should not use it directly, but only through library functions (for example, pthread_create (3) ); see also futex (7) used in the pthread_mutex * function
The clone script is used to create tasks: either threads (sharing the address space in a multi-threaded process), or processes.
The exit_group script is associated with exiting these tasks.
In short, you'll never use exit_group or clone directly. Your libc does this for you. So don't care about exit_group or _Exit ; you should use only the standard library function exit (3) , which is especially true for atexit (3) and on_exit (3) registered handlers and flushed <stdio.h> buffers. In rare cases, you do not want this to happen, use _ exit (2) (but you probably won't need it).
Of course, if you redefine your own libc from scratch, you need to take care of exit_group and clone ; but otherwise they donβt care. .
If you care about the details of the gory implementation, dive into the source code of your libc . Details can be libc version, kernel version and compiler specifics!
source share