News for hackers. Stuff that matters.
Re:The C standard library function atexit is broken by _rtld_global_ro on Wednesday June 19, 2019 @09:24PM (#20228980)
It's actually quite hard to do exit cleanups, even by putting functions into `.__fini_array`. The reason is because some signals (SIGTERM, SIGKILL) cannot be masked, when a thread/process (`task_struct`) got `SIGKILL`-ed, there's no way for application to run functions (including .__fini_array). Things can get more complicated when a thread calls `exit_group`, which is also recommended, cause all other threads in the same process group receive `SIGKILL`, hence none of the other threads are able to run any code after.
Re:The C standard library function atexit is broken by ryanpetrich on Wednesday June 19, 2019 @09:45PM (#20229099)
There's also the matter of someone forcibly pulling a machine's power cord. In some sense exit cleanups are fundamentally unreliable.
Re:The C standard library function atexit is broken by verall on Wednesday June 19, 2019 @11:26PM (#20229581)
A significant amount of code can be run after a power cord pull is detected but before the big caps discharge on most boxes. But yea no userspace program is going to get those cycles...
Re:The C standard library function atexit is broken by JoshTriplett on Wednesday June 19, 2019 @09:59PM (#20229156)
> The reason is because some signals (SIGTERM, SIGKILL) cannot be masked

SIGTERM can be masked. SIGKILL and SIGSTOP are the only ones that can't be.

Re:The C standard library function atexit is broken by _rtld_global_ro on Wednesday June 19, 2019 @11:16PM (#20229522)
Thanks for the correction