diff options
-rw-r--r-- | lib/libc/gen/sem_new.c | 4 | ||||
-rw-r--r-- | tools/regression/posixsem2/semtest.c | 4 |
2 files changed, 5 insertions, 3 deletions
diff --git a/lib/libc/gen/sem_new.c b/lib/libc/gen/sem_new.c index dbaf6e1..a4bb4f3 100644 --- a/lib/libc/gen/sem_new.c +++ b/lib/libc/gen/sem_new.c @@ -143,6 +143,7 @@ _sem_open(const char *name, int flags, ...) struct sem_nameinfo *ni = NULL; sem_t *sem = NULL; int fd = -1, mode, len; + int value = 0; if (name[0] != '/') { errno = EINVAL; @@ -170,6 +171,7 @@ _sem_open(const char *name, int flags, ...) if (flags & O_CREAT) { va_start(ap, flags); mode = va_arg(ap, int); + value = va_arg(ap, int); va_end(ap); } @@ -203,7 +205,7 @@ _sem_open(const char *name, int flags, ...) tmp._magic = SEM_MAGIC; tmp._kern._has_waiters = 0; - tmp._kern._count = 0; + tmp._kern._count = value; tmp._kern._flags = USYNC_PROCESS_SHARED | SEM_NAMED; if (_write(fd, &tmp, sizeof(tmp)) != sizeof(tmp)) { flock(fd, LOCK_UN); diff --git a/tools/regression/posixsem2/semtest.c b/tools/regression/posixsem2/semtest.c index 7557a61..befc7c5 100644 --- a/tools/regression/posixsem2/semtest.c +++ b/tools/regression/posixsem2/semtest.c @@ -58,10 +58,10 @@ test_named(void) printf("testing named process-shared semaphore\n"); sem_unlink(SEM_NAME); - s = sem_open(SEM_NAME, O_CREAT, 0777); + s = sem_open(SEM_NAME, O_CREAT, 0777, 0); if (s == SEM_FAILED) err(1, "sem_open failed"); - s2 = sem_open(SEM_NAME, O_CREAT, 0777); + s2 = sem_open(SEM_NAME, O_CREAT, 0777, 0); if (s2 == SEM_FAILED) err(2, "second sem_open call failed"); if (s != s2) |