Python os.tcsetpgrp() Method
The Python os.tcsetpgrp() method sets the process group ID associated with the terminal represented by a given file descriptor to an integer value. This file descriptor is obtained through the "os.open()" method.
NOTE: In operating systems like UNIX, each process belongs to a particular process group.
Syntax
Following is the syntax for Python os.tcsetpgrp() method −
os.tcsetpgrp(fd, pg)
Parameters
The Python os.tcsetpgrp() method accepts the below parameters −
fd − This is the file descriptor.
pg − This set the process group to pg.
Return Value
The Python os.tcsetpgrp() method does not return any value.
Example
The following example shows the usage of tcsetpgrp() method.
import os, sys
# Showing current directory
print ("Current working dir :%s" %os.getcwd())
# Changing dir to /dev/tty
fd = os.open("/dev/tty",os.O_RDONLY)
f = os.tcgetpgrp(fd)
# Showing the process group
print ("the process group associated is: ")
print (f)
# Setting the process group
os.tcsetpgrp(fd,2672)
print ("done")
os.close(fd)
print ("Closed the file successfully!!")
When we run above program, it produces following result −
Current working dir is :/tmp the process group associated is: 2672 done Closed the file successfully!!
python_files_io.htm
Advertisements