Created
October 27, 2022 08:53
-
-
Save alirezaarzehgar/e43341071d56fab1dc08d92abeda760c to your computer and use it in GitHub Desktop.
Example for signal, strsignal and pause functions (or syscalls).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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