signal handling

rlonstein via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Feb 7 09:50:40 PST 2015


On Friday, 6 February 2015 at 19:40:44 UTC, Danny wrote:
> Hi,
>
> if I want to clean up inside a signal handler and then exit the 
> process (as it would have without me handling it), what do I do?
>
> Can I exit() inside a signal handler or should I use a more 
> direct "quit now" function? (after all, it could have been in 
> the middle of relinking the free list when the signal arrived)

I'm using a basic C-style sigaction with core.sys.posix.signal 
and calling std.c.stdlib:exit. For context, I'm performing serial 
communication with an actual device so the signal may come when 
my code is blocked in an vendor API call or on an underlying 
syscall. I have very little state so I'm doing equally little 
beside freeing extern handles. Setting a global flag and testing 
it didn't really prove adequate and littered the checks 
everywhere so I'm thinking now of leveraging std.signals but I'm 
not sure that will be reliable.



More information about the Digitalmars-d-learn mailing list