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.
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.