1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
3 #include "cmGetPipes.h"
8 #if defined(_WIN32) && !defined(__CYGWIN__)
11 int cmGetPipes(int* fds
)
13 SECURITY_ATTRIBUTES attr
;
15 attr
.nLength
= sizeof(attr
);
16 attr
.lpSecurityDescriptor
= nullptr;
17 attr
.bInheritHandle
= FALSE
;
18 if (!CreatePipe(&readh
, &writeh
, &attr
, 0))
19 return uv_translate_sys_error(GetLastError());
20 fds
[0] = _open_osfhandle((intptr_t)readh
, 0);
21 fds
[1] = _open_osfhandle((intptr_t)writeh
, 0);
22 if (fds
[0] == -1 || fds
[1] == -1) {
25 return uv_translate_sys_error(GetLastError());
34 int cmGetPipes(int* fds
)
36 if (pipe(fds
) == -1) {
37 return uv_translate_sys_error(errno
);
40 if (fcntl(fds
[0], F_SETFD
, FD_CLOEXEC
) == -1 ||
41 fcntl(fds
[1], F_SETFD
, FD_CLOEXEC
) == -1) {
44 return uv_translate_sys_error(errno
);