tcsetpgrp() 方法設置通過 fd 給出與該終端相關聯的進程組(由 os.open() 返回一個打開的檔描述符)到 pg.
語法
當以下為 tcsetpgrp() 方法的語法:
os.tcsetpgrp(fd, pg)
參數
-
fd -- 這是在檔描述符
-
pg -- 這將設置進程組為pg
返回值
此方法不返回任何值。
示例
下麵的示例顯示 tcsetpgrp()方法的使用。
# !/usr/bin/python3 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!!"
當我們運行上面的程式,它會產生以下結果:
Current working dir is :/tmp the process group associated is: 2672 done Closed the file successfully!!
上一篇:
Python3檔方法
下一篇:
Python3 os檔目錄的方法