Python os.tcsetpgrp() Method
The method tcsetpgrp() sets the process group associated with the terminal given by fd (an open file descriptor as returned by os.open()) to pg.
Following is the syntax for tcsetpgrp() method:
fd -- This is the file descriptor.
pg -- This set the process group to pg.
This method does not return any value.
The following example shows the usage of tcsetpgrp() method.
# !/usr/bin/python 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!!