12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- #include <math.h>
- #include <signal.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #include <unistd.h>
- bool handle_ok = false;
- void handler(int sig)
- {
- printf("handle %d\n", sig);
- handle_ok = true;
- }
- int main()
- {
- printf("Test signal running...\n");
- signal(SIGKILL, &handler);
- printf("registered.\n");
- clock_t last = clock();
- while (1)
- {
- if ((clock() - last) / CLOCKS_PER_SEC >= 1)
- {
-
- last = clock();
- }
- if (handle_ok)
- {
- printf("Handle OK!\n");
- handle_ok = false;
- }
- }
- return 0;
- }
|