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.
SyntaxFollowing 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.
The Python os.tcsetpgrp() method does not return any value.
ExampleThe 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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4