[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] At-exit hook
From: |
Mailer |
Subject: |
Re: [PATCH] At-exit hook |
Date: |
Thu, 7 Nov 2024 12:27:00 +0000 |
On Thu, 7 Nov 2024 12:09:25 +0000
Mailer <vine24683579@gmail.com> wrote:
> On Thu, 7 Nov 2024 12:23:08 +0100
> Maxime Devos <maximedevos@telenet.be> wrote:
> > ‘atexit’ functions are run at ‘exit’. ‘exit’ can be run from signal
> > handlers (*). Since the hook runs Scheme code, it could do a lot of
> > AC-unsafe things, resulting in problems.
> >
> > (*) glibc documentation says ‘exit’ is AC-unsafe, but this is
> > unsupported by POSIX AFAICT. OTOH the same applies to even ‘malloc’,
> > so likely I’m looking in the wrong places.
>
> I think you meant async-signal-safe (AS-safe). 'exit' is not a-s-s and
> cannot be called in a signal handler (for example it can flush buffers)
> whereas '_exit' is a-s-s. Furthermore a registered handler cannot
> itself safely call 'exit'.
>
> I believe the main reason that use of 'atexit' or 'on_exit' is
> discouraged is that it does not handle abnormal process termination.
> (Registered handlers also don't run on termination by '_exit', but that
> is usually what you want.)
I believe also that use of 'atexit' is discouraged in dynamically linked
libraries because of the uncertain timing of the unloading of the
library, but I think in fact glibc is OK with this, so I guess it may
depend on your libc.
Chris
- [PATCH] At-exit hook, Mikael Djurfeldt, 2024/11/06
- RE: [PATCH] At-exit hook, Maxime Devos, 2024/11/07
- Re: [PATCH] At-exit hook, Mailer, 2024/11/07
- Re: [PATCH] At-exit hook,
Mailer <=
- Re: [PATCH] At-exit hook, Mikael Djurfeldt, 2024/11/07
- RE: [PATCH] At-exit hook, Maxime Devos, 2024/11/07
- Re: [PATCH] At-exit hook, Mailer, 2024/11/07
- RE: [PATCH] At-exit hook, Maxime Devos, 2024/11/07
- Re: [PATCH] At-exit hook, Mikael Djurfeldt, 2024/11/08
- Re: [PATCH] At-exit hook, Nala Ginrut, 2024/11/07