提交 89d3df6e 编写于 作者: R Rich Felker

streamline old-kernel fallback path of pipe2 to use syscalls directly

also, don't waste code/time on F_GETFL since pipes always have blank
flags initially (at least on old kernels, which are all this fallback
code matters for).
上级 d432b2c0
......@@ -11,12 +11,12 @@ int pipe2(int fd[2], int flag)
ret = __syscall(SYS_pipe, fd);
if (ret) return __syscall_ret(ret);
if (flag & O_CLOEXEC) {
fcntl(fd[0], F_SETFD, FD_CLOEXEC);
fcntl(fd[1], F_SETFD, FD_CLOEXEC);
__syscall(SYS_fcntl, fd[0], F_SETFD, FD_CLOEXEC);
__syscall(SYS_fcntl, fd[1], F_SETFD, FD_CLOEXEC);
}
if (flag & O_NONBLOCK) {
fcntl(fd[0], F_SETFL, fcntl(fd[0], F_GETFL) | O_NONBLOCK);
fcntl(fd[1], F_SETFL, fcntl(fd[1], F_GETFL) | O_NONBLOCK);
__syscall(SYS_fcntl, fd[0], F_SETFL, O_NONBLOCK);
__syscall(SYS_fcntl, fd[1], F_SETFL, O_NONBLOCK);
}
return 0;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册