VirtualBox

source: kBuild/trunk/src/lib/test-eintr-bug-1.c@ 2471

Last change on this file since 2471 was 2471, checked in by bird, 14 years ago

testing...

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.7 KB
Line 
1
2
3/*******************************************************************************
4* Header Files *
5*******************************************************************************/
6#define _XOPEN_SOURCE
7#define _BSD_SOURCE
8#include <sys/time.h>
9#include <sys/stat.h>
10#include <stdio.h>
11#include <signal.h>
12#include <string.h>
13#include <errno.h>
14
15
16static void SigAlaramHandler(int iSig)
17{
18 /* ignore */
19 (void)iSig;
20}
21
22
23int main(int argc, char **argv)
24{
25 struct itimerval TmrVal;
26 void (*rcSig)(int);
27 int i;
28 int rc;
29
30 /*
31 * Set up the timer signal.
32 */
33 rcSig = bsd_signal(SIGALRM, SigAlaramHandler);
34 if (rcSig == SIG_ERR)
35 {
36 fprintf(stderr, "bsd_signal failed: %s\n", strerror(errno));
37 return 1;
38 }
39 if (argc == 2) /* testing... */
40 siginterrupt(SIGALRM, 1);
41
42 memset(&TmrVal, '\0', sizeof(TmrVal));
43 TmrVal.it_interval.tv_sec = TmrVal.it_value.tv_sec = 0;
44 TmrVal.it_interval.tv_usec = TmrVal.it_value.tv_usec = 1000;
45 rc = setitimer(ITIMER_REAL, &TmrVal, NULL);
46 if (rc != 0)
47 {
48 fprintf(stderr, "setitimer failed: %s\n", strerror(errno));
49 return 1;
50 }
51
52 /*
53 * Do path related stuff.
54 */
55 for (i = 0; i < 100*1000*1000; i++)
56 {
57 struct stat St;
58 rc = stat(argv[0], &St);
59 if (rc != 0)
60 {
61 printf("iteration %d: stat: %u\n", i, errno);
62 break;
63 }
64 }
65
66 if (rc)
67 printf("No EINTR in %d iterations - system is working nicely!\n", i);
68
69 TmrVal.it_interval.tv_sec = TmrVal.it_value.tv_sec = 0;
70 TmrVal.it_interval.tv_usec = TmrVal.it_value.tv_usec = 0;
71 setitimer(ITIMER_REAL, &TmrVal, NULL);
72
73 return rc ? 1 : 0;
74}
75
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette