YouTip LogoYouTip

Os Tcsetpgrp

# Python2.x Python os.tcsetpgrp() Method [![Image 3: Python File Methods](#) Python OS File/Directory Methods](#) * * * ### Overview The os.tcsetpgrp() method is used to set the process group associated with terminal fd (an open file descriptor returned by os.open()) to pg. ### Syntax The syntax for the **tcsetpgrp()** method is as follows: os.tcsetpgrp(fd, pg) ### Parameters * **fd** -- File descriptor. * **pg** -- Associated process group. ### Return Value This method does not return a value. ### Example The following example demonstrates the usage of the tcsetpgrp() method: #!/usr/bin/python# -*- coding: UTF-8 -*-import os, sys # Display current directory print "current directory :%s" %os.getcwd()# modify directory to /dev/tty fd = os.open("/dev/tty",os.O_RDONLY) f = os.tcgetpgrp(fd)# Display process group print "associated process group: "print f # Set process group os.tcsetpgrp(fd,2672)print "done" os.close(fd)print "File closed successfully!!" Executing the above program outputs the following result: current directory :/tmp associated process group:2672doneFile closed successfully!! [![Image 4: Python File Methods](#) Python OS File/Directory Methods](#)
← Os TmpfileOs Tcsetpgrp β†’