1 #include "git-compat-util.h"
6 int enable_pipe_nonblock(int fd
)
8 int flags
= fcntl(fd
, F_GETFL
);
12 return fcntl(fd
, F_SETFL
, flags
);
15 #elif defined(GIT_WINDOWS_NATIVE)
19 int enable_pipe_nonblock(int fd
)
21 HANDLE h
= (HANDLE
)_get_osfhandle(fd
);
23 DWORD type
= GetFileType(h
);
24 if (type
== FILE_TYPE_UNKNOWN
&& GetLastError() != NO_ERROR
) {
28 if (type
!= FILE_TYPE_PIPE
)
29 BUG("unsupported file type: %lu", type
);
30 if (!GetNamedPipeHandleState(h
, &mode
, NULL
, NULL
, NULL
, NULL
, 0)) {
31 errno
= err_win_to_posix(GetLastError());
35 if (!SetNamedPipeHandleState(h
, &mode
, NULL
, NULL
)) {
36 errno
= err_win_to_posix(GetLastError());
44 int enable_pipe_nonblock(int fd
)