Python3 os.tcsetpgrp() Method
Python3 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.
Availability: Unix.Syntax
tcsetpgrp()The method syntax is as follows:
os.tcsetpgrp(fd, pg)
Parameters
fd-- file descriptor.
pg-- associated process group.
Return Value
This method has no return value.
Example
The following example demonstrates the use of the tcsetpgrp() method:
#!/usr/bin/python3
import os, sys
# 显示当前目录
print( "当前目录 :%s" %os.getcwd() )
# 修改目录到 /dev/tty
fd = os.open("/dev/tty",os.O_RDONLY)
f = os.tcgetpgrp(fd)
# 显示进程组
print( "关联进程组: " )
print( f )
# 设置进程组
os.tcsetpgrp(fd,2672)
print( "done" )
os.close(fd)
print( "关闭文件成功!!" )
The output of executing the above program is:
当前目录 :/tmp 关联进程组: 2672 done 关闭文件成功!!Other Extensions