Use pipe2() on non-Apple platforms

This commit is contained in:
Kovid Goyal 2018-06-08 08:15:12 +05:30
parent a1355484a6
commit 66dd83027d
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -111,6 +111,7 @@ handle_signal(int sig_num) {
static inline bool
self_pipe(int fds[2]) {
#ifdef __APPLE__
int flags;
flags = pipe(fds);
if (flags != 0) return false;
@ -123,6 +124,9 @@ self_pipe(int fds[2]) {
if (fcntl(fds[i], F_SETFL, flags | O_NONBLOCK) == -1) { return false; }
}
return true;
#else
return pipe2(fds, O_CLOEXEC | O_NONBLOCK) == 0;
#endif
}