previous: >>108219864
#define __NR_exit 60
#define __NR_exit_group 231
https://man7.org/linux/man-pages/man2/exit.2.html
https://man7.org/linux/man-pages/man2/exit_group.2.html
tl;dr:
exit causes your current thread to exit. if your current thread is the thread group leader, then it has the same effect as exit_group. that is, it causes your current process to exit
updating my tl;dr because i was WRONG (should've read the manpage first, i guess)
exit doesn't exit your process, even if you're the thread group leader. it still only exits that thread. it just keeps the leader thread in a zombie state until all of the other threads exit, or one of them calls exit_group
https://elixir.bootlin.com/linux/v6.19.3/source/kernel/exit.c#L918
https://elixir.bootlin.com/linux/v6.19.3/source/kernel/exit.c#L267
this is actually psychotic and one of the grossest things i have ever seen in linux
useful for skipping over any pesky atexit hooks. i never really understood the use case for those. like, sure, i understand how they work, and why you might want them in theory, but geeze. talk about niche use cases. when are you actually ever going to use these in the real world? something something graceful shutdown or whatever, but idk. feels pretty pointless. i guess the one actual use case is probably:
>Since glibc 2.2.3, atexit() (and on_exit(3)) can be used within a shared library to establish functions that are called when the shared library is unloaded.
that seems kind of handy. but for an actual process exit? nah
relevant resources:
man man
man syscalls
https://man7.org/linux/man-pages/
https://linux.die.net/man/
https://elixir.bootlin.com/linux/
https://elixir.bootlin.com/musl/
https://elixir.bootlin.com/glibc/