When the signal is delivered, the signal handler is executed on the stack of the process.
If SA_ONSTACK is used in sigaction()
, then a different stack is used.
What is the use of using different stack? Any use case example?
One use of an alternate stack is to try and handle SIGSEGV
properly.
If your process just received a SIGSEGV
because it exceeded its stack limit, you can't run the signal handler on the process's stack - it's full already. Having an alternate stack allows you to (carefully) run some more or less graceful shutdown in that case.