Python方法tcgetpgrp()返回与fd给定的终端相关联的进程组(由os.open()返回的打开文件描述符)
os.tcgetpgrp(fd) - 语法
os.tcgetpgrp(fd)
fd - 这是文件描述符。
os.tcgetpgrp(fd) - 返回值
此方法返回进程组。
os.tcgetpgrp(fd) - 示例
以下示例显示tcgetpgrp()方法的用法。
# !/usr/bin/pythonimport os, sys
# 显示当前目录 print "Current working dir :%s" %os.getcwd()
# 将目录更改为 /dev/tty fd=os.open("/dev/tty",os.O_RDONLY)
f=os.tcgetpgrp(fd)
# 显示进程组 print "the process group associated is: " print f
os.close(fd) print "Closed the file successfully!!"
当无涯教程运行上面的程序时,它产生以下输出-
Current working dir is :/tmp the process group associated is: 2670 Closed the file successfully!!