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.
SyntaxFollowing 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.
The Python os.mkfifo() method does not return any value.
ExampleThe 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 createdExample
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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4