diff options
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/gen/sem_new.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/libc/gen/sem_new.c b/lib/libc/gen/sem_new.c index 222a465..b748b49 100644 --- a/lib/libc/gen/sem_new.c +++ b/lib/libc/gen/sem_new.c @@ -162,10 +162,16 @@ _sem_open(const char *name, int flags, ...) _pthread_mutex_lock(&sem_llock); LIST_FOREACH(ni, &sem_list, next) { if (strcmp(name, ni->name) == 0) { - ni->open_count++; - sem = ni->sem; - _pthread_mutex_unlock(&sem_llock); - return (sem); + if ((flags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL)) { + _pthread_mutex_unlock(&sem_llock); + errno = EEXIST; + return (SEM_FAILED); + } else { + ni->open_count++; + sem = ni->sem; + _pthread_mutex_unlock(&sem_llock); + return (sem); + } } } |