I am wondering if there is a Windows equivalent for Linux mkfifo. By equivalent, I mean way of creating files, with st_mode S_IFIFO. Thanks for answers.
-
Windows just doesn't have the "everything is a file" abstraction, you'll need to make-do with a named pipe. Finding it back by name from the kernel object namespace is not a problem. – Hans Passant Jul 25 '15 at 11:08
-
I am just asking because Windows has _S_IFIFO defined, but maybe it's defined only for some backwards compatibility. Also ntfs-3g (from linux) recognizes some files as S_IFIFO. – Patrik Polakovic Jul 25 '15 at 13:27
-
Hmm, you found that in stat.h, a header that Microsoft had to emulate. Technically possible by wrapping a named pipe handle, it still isn't a file. – Hans Passant Jul 25 '15 at 13:39
1 Answers
It should be possible to emulate the mkfifo
behavior to some degree. I have implemented something like that many years ago for OS/2 which is quite similar to WinXX with respect to the file system.
The main restriction is that Windows uses reserved file names for pipes: \\.\pipe\pipename or \\servername\pipe\pipename over the network (which can be very useful). But you will not be able to use arbitrary fifo names directly. The pipe names need the \\.\pipe\ prefix.
However, an application could create a pipe with CreateNamedPipe
with PIPE_ACCESS_DUPLEX
and e.g. a GUID name and create a symbolic link to this pipe in the target directory with DeviceIoControl
/ FSCTL_SET_REPARSE_POINT
. This should be quite close to mkfifo
.
The drawback is that the application that services the pipe must run as long as the pipe instance exists. And, of course, it should clean up the symbolic link on termination. Furthermore it needs to read all data from the pipe and write it back again. Not sure whether this can be implemented with zero copy.
There are some further aspects. E.g. if you want to be able to delete your emulated FIFO you need to track the deletion of the symbolic link and terminate the worker process in this case.
I am sorry, I have no Windows development environment so I can't test this approach.

- 1,688
- 1
- 14
- 25
-
thank you for your reply. I wasn't really trying to create such file. I asked because on linux systems, ntfs-3g driver actually does recognize some files on NTFS partition as FIFO\SOCKET. And reading from such file unexpectedly hangs. It's the feature of ntfs-3g FUSE driver. `> fsutil file createnew fifo 0 > fsutil file createnew socket 1 > attrib +S -H fifo > attrib +S -H socket` – Patrik Polakovic Nov 16 '17 at 14:16
-
I have tried to create a symbolic link to a path starting with `\\.\pipe` and I couldn't get it working. See [this](https://superuser.com/questions/1265561/create-a-symbolic-link-to-a-named-pipe) question. – IS4 Jan 01 '18 at 11:14