Changeset 2474 in kBuild for trunk/src/lib
- Timestamp:
- Jul 12, 2011 2:43:14 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/test-eintr-bug-2.c
r2472 r2474 8 8 #include <sys/time.h> 9 9 #include <sys/stat.h> 10 #include <fcntl.h> 10 11 #include <time.h> 11 12 #include <stdio.h> … … 14 15 #include <pthread.h> 15 16 #include <signal.h> 17 #include <unistd.h> 16 18 17 19 … … 21 23 /** The number of signals. */ 22 24 static volatile long g_cSigs = 0; 25 /** Number of signals received on threads other than the main one. */ 26 static volatile long g_cSigsOther = 0; 23 27 /** Whether to shutdown or not. */ 24 28 static volatile int g_fShutdown = 0; … … 30 34 { 31 35 g_cSigs++; 36 if (pthread_self() != g_hMainThread) 37 g_cSigsOther++; 32 38 33 39 (void)iSig; … … 46 52 static void *ThreadProc(void *pvIgnored) 47 53 { 54 int volatile i = 0; 48 55 while (!g_fShutdown) 49 56 { 50 NanoSleep(850);57 // NanoSleep(850); 51 58 if (g_fShutdown) 52 59 break; 53 60 54 61 pthread_kill(g_hMainThread, SIGALRM); 62 for (i = 6666; i > 0; i--) 63 /* nothing */; 55 64 } 56 65 return NULL; … … 101 110 { 102 111 struct stat St; 112 int fd; 103 113 104 114 rc = stat(argv[0], &St); … … 110 120 break; 111 121 } 122 123 fd = open(szName, O_CREAT | O_RDWR, 0666); 124 if (errno == EINTR && fd < 0) 125 { 126 printf("iteration %d: open: %u\n", i, errno); 127 break; 128 } 129 close(fd); 130 rc = unlink(szName); 131 if (errno == EINTR && rc != 0) 132 { 133 printf("iteration %d: unlink: %u\n", i, errno); 134 break; 135 } 136 137 /* Show progress info */ 112 138 if ((i % 100000) == 0) 113 139 { 114 140 printf("."); 115 141 if ((i % 1000000) == 0) 116 printf("[%d/%ld ]", i, g_cSigs);142 printf("[%d/%ld/%ld]\n", i, g_cSigs, g_cSigsOther); 117 143 fflush(stdout); 118 144 }
Note:
See TracChangeset
for help on using the changeset viewer.