1 #include <common.h>
2 
3 int
4 main(void) {
5 	sem_t id;
6 
7 	if (sem_init(&id, 0, 1) < 0) {
8 		perror("sem_init");
9 		return 1;
10 	}
11 
12 	/* This should succeed and decrement the value to 0. */
13 	if (sem_trywait(&id) < 0) {
14 		perror("sem_trywait()");
15 		sem_destroy(&id);
16 		return 1;
17 	}
18 	if (checkvalue(&id, 0) < 0) {
19 		sem_destroy(&id);
20 		return 1;
21 	}
22 
23 	if (sem_destroy(&id) < 0) {
24 		perror("sem_destroy");
25 		return 1;
26 	}
27 	return 0;
28 }
29