Python os.tcsetpgrp() Method
os.tcsetpgrp() Overview
The os.tcsetpgrp() method is used to set the process group associated with the terminal fd (an open file descriptor returned by os.open()) to pg.
Available systems: Unix.
os.tcsetpgrp() Syntax
The syntax format of tcsetpgrp() method is as follows.
os.tcsetpgrp(fd, pg)
os.tcsetpgrp() Parameters
- fd – File descriptor.
- pg – Associated process group.
os.tcsetpgrp() Return Value
This method has no return value.
os.tcsetpgrp() Example#1
The following example demonstrates the use of the tcsetpgrp() method.
#!/usr/bin/python3
import os, sys
# Show current directory
print( "Current directory :%s" %os.getcwd() )
# Modify the directory to /dev/tty
fd = os.open("/dev/tty",os.O_RDONLY)
f = os.tcgetpgrp(fd)
# Show process groups
print( "Associated process groups: " )
print( f )
# Setting up process groups
os.tcsetpgrp(fd,f)
print( "done" )
os.close(fd)
Output: