scope(exit) and Ctrl-C

H. S. Teoh hsteoh at quickfur.ath.cx
Sun Dec 3 02:56:38 UTC 2017


On Sat, Dec 02, 2017 at 11:32:17AM +0000, Patrick Schluter via Digitalmars-d-learn wrote:
> On Saturday, 2 December 2017 at 04:49:26 UTC, H. S. Teoh wrote:
> > On Sat, Dec 02, 2017 at 04:38:29AM +0000, Adam D. Ruppe via
> > Digitalmars-d-learn wrote:
> > > [...]
> > 
> > Signal handlers can potentially be invoked while inside a
> > non-reentrant libc or OS function, so trying to do anything that
> > (indirectly or otherwise) calls that function will cause havoc to
> > your program.  Also, while the signal handler is running, some
> > (all?) further signals may be blocked, meaning that your program
> > might miss an important signal if your sig handler takes too long to
> > run.  Furthermore, the signal may have happened in the middle of
> > your own code, so race conditions may apply (e.g. if you're
> > modifying global data in both).
> > 
> > [...]
> 
> On Linux you can use signalfd() for that, but nice trick if you want
> Posix portability.

Ha! I've been using Linux for decades now and this is the first time I'm
aware of this function.  Should simplify my code when I'm not planning
to be Posix-portable. Thanks!


T

-- 
Heads I win, tails you lose.


More information about the Digitalmars-d-learn mailing list