www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - What is wrong with core.stdc.signal ?

reply angel <andrey.gelman gmail.com> writes:
Core.stdc.signal.signal() requires that a signal handler function 
is "nothrow  nogc  system".
These attributes impose quite a limitation - one cannot even 
print which signal was accepted.
While if one imports this same function via "extern (C)" path, he 
can  freely throw and allocate memory in the signal handler. And 
this actually makes sense, as the handler function is called on 
top of the stack of where the code was running when the signal 
popped in, so it's like calling a function.
Why the limitation if it works ?
Oct 27 2017
parent ketmar <ketmar ketmar.no-ip.org> writes:
angel wrote:

 Core.stdc.signal.signal() requires that a signal handler function is 
 "nothrow  nogc  system".
 These attributes impose quite a limitation - one cannot even print which 
 signal was accepted.
'cause you CANNOT print in signal handler. you can do almost *nothing* in signal handler besides setting some variable. please, read the OS manuals about signals.
Oct 27 2017