signal hanldlers
Of course, I knew the basics about signals like SIGKILL -9, Ctrl+D and such. However, it didn’t fully click for me about how signal handling is done at the assembler level.
When you register a handler similar to the following C code:
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
void handle_sigusr1(int sig) {
printf("\nReceived SIGUSR1 signal\n");
}
int main() {
signal(SIGUSR1, handle_sigusr1);
while(1) {
printf("\n");
}
}
Your output assemly will have a special function to which regular processing will stop and jump to that block. The execution will continue at the exact spot it left off.