1 #ifndef DASYNQ_UTIL_H_INCLUDED
2 #define DASYNQ_UTIL_H_INCLUDED 1
4 #include <dasynq-config.h>
9 // Define pipe2, if it's not present in the sytem library. pipe2 is like pipe with an additional flags
10 // argument which can set file/descriptor flags atomically. The emulated version that we generate cannot
11 // do this atomically, of course.
13 #if DASYNQ_HAVE_PIPE2 == 0
14 inline int pipe2(int filedes[2], int flags)
16 if (pipe(filedes) == -1) {
20 if (flags & O_CLOEXEC) {
21 fcntl(filedes[0], F_SETFD, FD_CLOEXEC);
22 fcntl(filedes[1], F_SETFD, FD_CLOEXEC);
25 if (flags & O_NONBLOCK) {
26 fcntl(filedes[0], F_SETFL, O_NONBLOCK);
27 fcntl(filedes[1], F_SETFL, O_NONBLOCK);