Python os.mkfifo() Method



The Python method os.mkfifo() creates a FIFO named path with a numeric mode. The default mode is "0o666" (octal) which sets the read and write permissions for a given file..

The term FIFO stands for First In First Out. In Unix-like operating systems, it is a named pipe used for storing data in a temporary queue where the first data written into the pipe is the first to read out.

Syntax

Following is the syntax for Python os.mkfifo() method −

os.mkfifo(path, mode, * , dir_fd)

Parameters

The Python os.mkfifo() method accepts the following parameters −

  • path − This is the path, which needs to be created.

  • mode − This is the mode of the named path to be given.

  • dir_fd − This parameter represents a file descriptor that refers to a directory. Its default value is "None".

  • * − This parameter indicates that all following parameters (in this case, dir_fd) are keyword-only parameters.

Return Value

The Python os.mkfifo() method does not return any value.

Example

The following example shows the usage of mkfifo() method. Here, we are creating a FIFO named pipe "/tmp/new".

import os, sys

# Path to be created
path = "/tmp/new"

os.mkfifo( path )
print ("Path is created")

When we run the above program, it produces following result −

Path is created

Example

In the following example, we are creating a FIFO named pipe with the specified mode using mkfifo() method.

import os, sys

# Path to be created
path = "/home/tp/Python/nwdir/new"

os.mkfifo(path, 0o600)
print ("Path created with read and write permission")

When we run above program, it produces following result −

Path created with read and write permission
python_files_io.htm
Advertisements
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy