2 /* Do stupid things with semaphores, and check that Thrcheck doesn't
3 fall over and does report errors appropriately. If nothing else
4 this just checks that the relevant functions are getting
7 /* This is pretty lame, because making the sem_ functions fail is
8 difficult. Not sure it's really worth having. */
14 #include "safe-semaphore.h"
16 void start_watchdog ( void );
19 int r
__attribute__((unused
));
22 /* Do sem_init with huge initial count */
23 r
= sem_init(&s1
, 0, ~0);
25 /* initialise properly */
26 r
= sem_init(&s1
, 0, 0);
28 /* in glibc, sem_destroy is a no-op; making it fail is
31 /* Do 'wait' on a bogus semaphore. This should fail, but on glibc
33 memset(&s1
, 0x55, sizeof(s1
));
34 r
= sem_wait(&s1
); /* assert(r != 0); */
35 #if defined(VGO_solaris)
39 /* this only fails with glibc 2.7 and later. */
47 void* watchdog ( void* v
)
50 fprintf(stderr
, "watchdog timer expired - not a good sign\n");
54 void start_watchdog ( void )
58 r
= pthread_create(&t
, NULL
, watchdog
, NULL
);