home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!psinntp!ncrlnk!usglnk!usdsd1!dkowalsk
- From: dkowalsk@usdsd1.DaytonOH.NCR.COM (Dennis Kowalski)
- Newsgroups: comp.unix.questions
- Subject: Interval Timer functions (setitimer)
- Message-ID: <1901@usdsd1.DaytonOH.NCR.COM>
- Date: 23 Nov 92 15:18:58 GMT
- Reply-To: dkowalsk@usdsd1.DaytonOH.NCR.COM (Dennis Kowalski)
- Distribution: world
- Organization: NCR USG Data Services Division
- Lines: 56
-
-
- I need help!!!
-
- I am trying to use the setitimer function to cause an interupt in 5 seconds.
- I have tried all three timers (ITIMER_REAL ITIMER_VIRTUAL & ITIMER_PROF with
- no luck with any of them.
-
- I have played around with all possible options of it_value & it_interval.
-
- The following code is how I think it should be.
- The pause statement is never interupted .
-
- I have tried this under 5.3 & 5.4.
-
- Can anyone show me the error of my ways???
-
- #include <signal.h>
- #include <sys/time.h>
-
- void itimer_rtn();
-
- struct itimerval dktimer1, dktimer2;
-
- main()
- {
- if (signal (SIGPROF, itimer_rtn) == SIG_ERR)
- {
- printf("\nSet of SIGPROF failed\n");
- exit(1);
- }
-
- dktimer1.it_value.tv_sec = 5;
- dktimer1.it_value.tv_usec = 0;
- dktimer1.it_interval.tv_sec = 0;
- dktimer1.it_interval.tv_usec = 0;
- stat = setitimer(ITIMER_PROF, &dktimer1, NULL);
-
- printf("\nPausing\n");
- pause();
- printf("came back from pause\n"); /* NEVER GETS TO HERE */
- exit(0);
-
- }
-
- void itimer_rtn()
- {
-
- printf("\nGot SIGPROF \n"); /* NEVER HAPPENS */
- return;
- }
-
- --
- Dennis Kowalski NCR Corporation PCD-3 (513) 445-1843
- Systems Architecture 1700 S. Patterson Blvd VOICEplus 622-1843
- USG Data Services Div Dayton, Ohio 45479
- Dennis.Kowalski@DaytonOH.NCR.COM
-