Python os.tcgetpgrp() 方法
概述
os.tcgetpgrp() 方法用於回與終端fd(一個由os.open()返回的打開的文件描述符)關聯的進程組。
語法
tcgetpgrp()方法語法格式如下:
os.tcgetpgrp(fd)
參數
fd --文件描述符。
返回值
該方法返回進程組。
實例
以下實例演示了tcgetpgrp() 方法的使用:
#!/usr/bin/python # -*- coding: UTF-8 -*- 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 关闭文件成功!!