Python pty openpty()














































Python pty openpty()



Introduction :
The full form of pty is Pseudo Terminal Utilities. The module is defined to handle Pseudo-terminal concepts. In this, we can start another process and also can write to and read from its controlling terminal using programs.

Method Name : pty.openpty()
Description : The method openpty() will open a pseudo-terminal pair,using os.openty() and it will return a pair of file descriptors(master,slave) for the pty .
In this article, I will be introducing the pty.openpty() module.
This method returns a pair of file descriptors i.e., master and slave.The returned file descriptors are non-inheritable. we will know about what is pseudo terminal so it is a device having the functions of a physics terminal without being actually one.This method is only available on some parts of linux system.

The first step would be to import the pty module.  
cmd command:
import pty.openpty()

Example :
Code :
import pty, os master, slave = pty.openpty() print('Name of the Master: ' + str(os.ttyname(master))) print('Name of the Slave: ' + str(os.ttyname(slave)))

Output


Comments