I did read that signals need to have a separate stack, why and how do you think it is implemented ?
Are they dynamically allocated or statically allocated ? How is memory allocation done ? Is it the same for all signals ?
A signal stack is a special area of memory to be used as the execution stack during signal handlers. It should be fairly large, to avoid any danger that it will overflow in turn; the macro SIGSTKSZ is defined to a canonical size for signal stacks. You can use malloc to allocate the space for the stack.
A signal handler is a function which is called by the target environment when the corresponding signal occurs. The target environment suspends execution of the program until the signal handler returns or calls longjmp() . Signal handlers can be set with signal() or sigaction() .
The reason that signals need a separate stack is that, if the normal stack gets corrupted or overflows, the signal can still execute. I think the signal stack is usually allocated dynamically, but it could implemented be either way. You can set a new signal stack with sigaltstack
. It is the same for all signals.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With