Os Tcsetpgrp
# Python2.x Python os.tcsetpgrp() Method
[ Python OS File/Directory Methods](#)
* * *
### 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`.
### Syntax
The syntax for the **`tcsetpgrp()`** method is as follows:
os.tcsetpgrp(fd, pg)
### Parameters
* **fd** -- The file descriptor.
* **pg** -- The associated process group.
### Return Value
This method does not return a value.
### Example
The following example demonstrates the use 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!!"
The output of executing the above program is:
current directory :/tmp associated process group:2672doneFile closed successfully!!
[ Python OS File/Directory Methods](#)
YouTip