| #include "git-compat-util.h" |
| int enable_pipe_nonblock(int fd) |
| int flags = fcntl(fd, F_GETFL); |
| return fcntl(fd, F_SETFL, flags); |
| #elif defined(GIT_WINDOWS_NATIVE) |
| int enable_pipe_nonblock(int fd) |
| HANDLE h = (HANDLE)_get_osfhandle(fd); |
| DWORD type = GetFileType(h); |
| if (type == FILE_TYPE_UNKNOWN && GetLastError() != NO_ERROR) { |
| if (type != FILE_TYPE_PIPE) |
| BUG("unsupported file type: %lu", type); |
| if (!GetNamedPipeHandleState(h, &mode, NULL, NULL, NULL, NULL, 0)) { |
| errno = err_win_to_posix(GetLastError()); |
| if (!SetNamedPipeHandleState(h, &mode, NULL, NULL)) { |
| errno = err_win_to_posix(GetLastError()); |
| int enable_pipe_nonblock(int fd UNUSED) |