提交 682a0f27 编写于 作者: R Rich Felker

fix failure behavior of sem_open when sem does not exist

上级 cfe581b6
......@@ -100,7 +100,7 @@ sem_t *sem_open(const char *name, int flags, ...)
close(tfd);
unlink(tmp);
}
if (fstat(fd, &st) < 0) {
if (fd >= 0 && fstat(fd, &st) < 0) {
close(fd);
fd = -1;
}
......@@ -118,6 +118,10 @@ sem_t *sem_open(const char *name, int flags, ...)
break;
}
}
if (!(flags & O_CREAT)) {
pthread_spin_unlock(&lock);
return SEM_FAILED;
}
if (!linkat(AT_FDCWD, tmp, dir, name, 0)) {
fd = tfd;
close(dir);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册