Skip to content

os: support creating FIFOs on Windows #103510

Open
@RayyanAnsari

Description

@RayyanAnsari

os.mkfifo() creates a named pipe that is accessible on the file system. It is currently only supported on Unix.
Windows also supports creating named pipes with CreateNamedPipeW() which returns a handle to the server end of the pipe. However, they can only be created on a special filesystem in the \\.\pipe\ directory.

The Windows docs say that:

An instance of a named pipe is always deleted when the last handle to the instance of the named pipe is closed.

And os.mkfifo doesn't return the pipe handles, it just creates the pipe:

Note that mkfifo() doesn’t open the FIFO — it just creates the rendezvous point.

This would mean that implementing Windows support into os.mkfifo would mean that the pipe is deleted as soon as it is created (if we close the handle returned by CreateNamedPipeW()), or we have a pipe that we can't delete (if we leave the pipe handle open).
Unless there is some way to pass that back to the calling code - like os.pipe() that's supported on Windows.

I'm not sure how I would go about implementing this. Returning the handle only on Windows? Making a new cross-platform function that always returns the handle (perhaps called os.fifo)?

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions