home *** CD-ROM | disk | FTP | other *** search
/ ftp.disi.unige.it / 2015-02-11.ftp.disi.unige.it.tar / ftp.disi.unige.it / pub / .person / GianuzziV / SO1 / WSignal.cpp < prev   
C/C++ Source or Header  |  2001-11-11  |  740b  |  38 lines

  1. // IntrC.cpp
  2.  
  3. #include "stdafx.h"
  4. #include "IntrC.h"
  5. #include "process.h"
  6. #include "signal.h"
  7.  
  8. void intr_ctrC(int sig)   // catch ^C and end on request
  9. {
  10.    char ch[2];
  11.  
  12.    signal(SIGINT, intr_ctrC);  // catch ^C
  13.    printf("Do you really want to abort? (y) > ");
  14.  
  15.    scanf("%s", ch);
  16.    if ('y'==ch[0]) exit(1);
  17.    return;
  18. }
  19.  
  20. int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
  21. {
  22.     // initialize MFC and print and error on failure
  23.     if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
  24.    {
  25.       printf("Fatal Error: MFC initialization failed\n");
  26.       exit(1);
  27.     }
  28.  
  29.     signal(SIGINT, intr_ctrC);  // catch ^C
  30.     for (;;)
  31.     {
  32.       printf("sto lavorando per voi \n");
  33.       Sleep(1000);
  34.      }
  35.     return 0;
  36. }
  37.  
  38.