Beispiel #1
0
static int uv__make_pipe(int fds[2], int flags) {
#if HAVE_SYS_PIPE2
  int fl;

  fl = O_CLOEXEC;

  if (flags & UV__F_NONBLOCK)
    fl |= O_NONBLOCK;

  if (sys_pipe2(fds, fl) == 0)
    return 0;

  if (errno != ENOSYS)
    return -1;

  /* errno == ENOSYS so maybe the kernel headers lied about
   * the availability of pipe2(). This can happen if people
   * build libuv against newer kernel headers than the kernel
   * they actually run the software on.
   */
#endif

  if (pipe(fds))
    return -1;

  uv__cloexec(fds[0], 1);
  uv__cloexec(fds[1], 1);

  if (flags & UV__F_NONBLOCK) {
    uv__nonblock(fds[0], 1);
    uv__nonblock(fds[1], 1);
  }

  return 0;
}
Beispiel #2
0
int pipe2(int pipefd[2], int flags)
{
	return sys_pipe2(pipefd, flags);
}