Python3 os.tcgetpgrp() 方法
概述
os.tcgetpgrp() 方法用於回與終端fd(一個由os.open()返回的打開的檔描述符)關聯的進程組。
語法
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 ("相關進程組: ")
print (f)
os.close(fd)
print ("關閉檔成功!!")
執行以上程式輸出結果為:
當前目錄 :/tmp 相關進程組: 2670 關閉檔成功!!

Python3 OS 檔/目錄方法