xref: /dragonfly/test/testcases/posixipc/create_excl_existing_sem/create_excl_existing_sem.c (revision 0bba68feaae2960c1f2b5feb6978a8918f571707)
1 #include <common.h>
2 
3 int
main(void)4 main(void) {
5           int retval = 0;
6           sem_t *id;
7 
8           id = sem_open(TEST_PATH, O_CREAT, 0777, 1);
9           if (id == SEM_FAILED) {
10                     perror("sem_open(O_CREAT)");
11                     return 1;
12           }
13           sem_close(id);
14 
15           retval = sem_open_should_fail(TEST_PATH, O_CREAT | O_EXCL, 0777, 1, EEXIST);
16 
17           sem_unlink(TEST_PATH);
18 
19           return retval;
20 }
21