Skip to content

Instantly share code, notes, and snippets.

@alirezaarzehgar
Created October 27, 2022 08:53
Show Gist options
  • Select an option

  • Save alirezaarzehgar/e43341071d56fab1dc08d92abeda760c to your computer and use it in GitHub Desktop.

Select an option

Save alirezaarzehgar/e43341071d56fab1dc08d92abeda760c to your computer and use it in GitHub Desktop.
Example for signal, strsignal and pause functions (or syscalls).
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdbool.h>
#include <signal.h>
void sig_handler(int signo)
{
printf("Yo yo : %s\n", strsignal(signo));
}
int main(int argc, char const *argv[])
{
printf("pid : %d\n", getpid());
for (int signo = 0; signo < 32; signo++)
{
signal(signo, sig_handler);
printf("%s handled\n", strsignal(signo));
}
while (true)
pause();
return (EXIT_SUCCESS);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment