How do C signals interact with the stack?
We know how C functions work. The program maintains a call stack, which contains stack frames corresponding to nested function calls. Calling a function means pushing a new stack frame onto the stack, and returning from a function means popping its stack frame off the stack.
C signal handlers are functions, but the calling mechanism is clearly different. They don’t get called in a “normal” way, and they don’t get to “return” a value. So how do these functions work? And how do they interact with “normal” C functions?
The BSD manual for
Normally, signal handlers execute on the current stack of the process. This may be changed, on a per-handler basis, so that signals are taken on a special signal stack.
So signal handlers do reuse the same stack, under normal conditions.
More by Jim
- The inception bar: a new phishing method
- The hacker hype cycle
- Project C-43: the lost origins of asymmetric crypto
- How Hacker News stays interesting
- My parents are Flat-Earthers
- The dots do matter: how to scam a Gmail user
- The sorry state of OpenSSL usability
- I hate telephones
- The Three Ts of Time, Thought and Typing: measuring cost on the web
- Granddad died today
- Your syntax highlighter is wrong
Tagged . All content copyright James Fisher 2017. This post is not associated with my employer. Found an error? Edit this page.