Python 3 教程
os.tcgetpgrp() 方法用于回與終端fd(一個由os.open()返回的打開的文件描述符)關(guān)聯(lián)的進程組。
tcgetpgrp()方法語法格式如下:
os.tcgetpgrp(fd)
fd -- 文件描述符。
該方法返回進程組。
以下實例演示了 tcgetpgrp() 方法的使用:
#!/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 ("相關(guān)進程組: ") print (f) os.close(fd) print ("關(guān)閉文件成功!!")
執(zhí)行以上程序輸出結(jié)果為:
當前目錄 :/tmp 相關(guān)進程組: 2670 關(guān)閉文件成功!!其他擴展