mirror of
https://git.musl-libc.org/git/musl
synced 2025-03-31 23:13:08 +03:00
fix failure behavior of sem_open when sem does not exist
This commit is contained in:
parent
cfe581b6bc
commit
682a0f271f
@ -100,7 +100,7 @@ sem_t *sem_open(const char *name, int flags, ...)
|
|||||||
close(tfd);
|
close(tfd);
|
||||||
unlink(tmp);
|
unlink(tmp);
|
||||||
}
|
}
|
||||||
if (fstat(fd, &st) < 0) {
|
if (fd >= 0 && fstat(fd, &st) < 0) {
|
||||||
close(fd);
|
close(fd);
|
||||||
fd = -1;
|
fd = -1;
|
||||||
}
|
}
|
||||||
@ -118,6 +118,10 @@ sem_t *sem_open(const char *name, int flags, ...)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!(flags & O_CREAT)) {
|
||||||
|
pthread_spin_unlock(&lock);
|
||||||
|
return SEM_FAILED;
|
||||||
|
}
|
||||||
if (!linkat(AT_FDCWD, tmp, dir, name, 0)) {
|
if (!linkat(AT_FDCWD, tmp, dir, name, 0)) {
|
||||||
fd = tfd;
|
fd = tfd;
|
||||||
close(dir);
|
close(dir);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user