Brian Dessent wrote: > > However, I'm not sure on mingw how to detect whether an fd is open on a > > regular file vs. a pipe. Any ideas? > > Check out ser-mingw.c from gdb, they have a fair amount of MinGW pipe/fd > handling code there, e.g. > > static int > fd_is_pipe (int fd) > { > if (PeekNamedPipe ((HANDLE) _get_osfhandle (fd), NULL, 0, NULL, NULL, > NULL)) > return 1; > else > return 0; > }
But there are other types of devices as well, such as special character devices (COM: and consoles). It looks safer to include only the regular files: GetFileType ((HANDLE) _get_osfhandle (fd)) == FILE_TYPE_DISK. Bruno