home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / unix / question / 13846 < prev    next >
Encoding:
Text File  |  1992-11-23  |  1.7 KB  |  68 lines

  1. Path: sparky!uunet!psinntp!ncrlnk!usglnk!usdsd1!dkowalsk
  2. From: dkowalsk@usdsd1.DaytonOH.NCR.COM (Dennis Kowalski)
  3. Newsgroups: comp.unix.questions
  4. Subject: Interval Timer functions (setitimer)
  5. Message-ID: <1901@usdsd1.DaytonOH.NCR.COM>
  6. Date: 23 Nov 92 15:18:58 GMT
  7. Reply-To: dkowalsk@usdsd1.DaytonOH.NCR.COM (Dennis Kowalski)
  8. Distribution: world
  9. Organization: NCR USG Data Services Division
  10. Lines: 56
  11.  
  12.  
  13. I need help!!!
  14.  
  15. I am trying to use the setitimer function to cause an interupt in 5 seconds.
  16. I have tried all three timers (ITIMER_REAL  ITIMER_VIRTUAL & ITIMER_PROF with
  17. no luck with any of them.
  18.  
  19. I have played around with all possible options of it_value & it_interval.
  20.  
  21. The following code is how I think it should be.
  22. The pause statement is never interupted .
  23.  
  24. I have tried this under 5.3 & 5.4.
  25.  
  26. Can anyone show me the error of my ways???
  27.  
  28. #include <signal.h>
  29. #include <sys/time.h>
  30.  
  31. void itimer_rtn();
  32.  
  33. struct itimerval  dktimer1, dktimer2;
  34.  
  35. main()
  36. {
  37.   if (signal (SIGPROF, itimer_rtn) == SIG_ERR)
  38.   {
  39.         printf("\nSet of SIGPROF failed\n");
  40.         exit(1);
  41.   }
  42.  
  43.   dktimer1.it_value.tv_sec = 5;
  44.   dktimer1.it_value.tv_usec = 0;
  45.   dktimer1.it_interval.tv_sec = 0;
  46.   dktimer1.it_interval.tv_usec = 0;
  47.   stat = setitimer(ITIMER_PROF, &dktimer1, NULL);
  48.  
  49.   printf("\nPausing\n");
  50.   pause();
  51.   printf("came back from pause\n");    /* NEVER GETS TO HERE */
  52.   exit(0);
  53.  
  54. }
  55.  
  56. void itimer_rtn()
  57. {
  58.  
  59.   printf("\nGot SIGPROF \n");   /* NEVER HAPPENS */
  60.   return;
  61. }
  62.  
  63. -- 
  64. Dennis Kowalski         NCR Corporation  PCD-3                  (513) 445-1843
  65. Systems Architecture    1700 S. Patterson Blvd              VOICEplus 622-1843
  66. USG Data Services Div   Dayton, Ohio     45479
  67. Dennis.Kowalski@DaytonOH.NCR.COM
  68.