home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / unix / emx / test / sig3.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-02  |  596 b   |  38 lines

  1. /* sig3.c (emx+gcc) */
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <signal.h>
  6. #include <setjmp.h>
  7.  
  8. static jmp_buf jump;
  9.  
  10. static void handler (int sig)
  11. {
  12.   printf ("Signal %d received\n", sig);
  13.   signal (sig, SIG_ACK);
  14.   longjmp (jump, 1);
  15. }
  16.  
  17. int main (void)
  18. {
  19.   int c;
  20.  
  21.   if (signal (SIGINT, handler) == SIG_ERR)
  22.     {
  23.       puts ("signal failed");
  24.       return (1);
  25.     }
  26.   if (setjmp (jump) != 0)
  27.     puts ("jumped");
  28.   for (;;)
  29.     {
  30.       c = fgetchar ();
  31.       if (c == EOF)
  32.         break;
  33.       putchar (c);
  34.     }
  35.   putchar ('\n');
  36.   return (0);
  37. }
  38.