AC_MSG_RESULT([$sysdep_dirs])
AC_SUBST([sysdep_dirs])
+AC_CHECK_FUNCS([pipe2])
+
if test "$with_iproutedir" = no ; then with_iproutedir= ; fi
if test -n "$given_iproutedir"
* Can be freely distributed and used under the terms of the GNU GPL.
*/
+#define _GNU_SOURCE
+
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void
pipe_new(struct pipe *p)
{
+ int flags = O_NONBLOCK | O_CLOEXEC;
+#if HAVE_PIPE2
+ int rv = pipe2(p->fd, flags);
+ if (rv < 0)
+ die("pipe2: %m");
+#else
int rv = pipe(p->fd);
if (rv < 0)
die("pipe: %m");
- if (fcntl(p->fd[0], F_SETFL, O_NONBLOCK) < 0)
+ if (fcntl(p->fd[0], F_SETFL, flags) < 0)
die("fcntl(O_NONBLOCK): %m");
- if (fcntl(p->fd[1], F_SETFL, O_NONBLOCK) < 0)
+ if (fcntl(p->fd[1], F_SETFL, flags) < 0)
die("fcntl(O_NONBLOCK): %m");
+#endif
}
void