Python-os-tcgetpgrp
提供:Dev Guides
Python os.tcgetpgrp()メソッド
説明
Pythonメソッド* tcgetpgrp()*は、fd(http://www.finddevguides.com/python/os_open [os.open()]によって返されるオープンファイル記述子)によって指定された端末に関連付けられたプロセスグループを返します
構文
以下は、* tcgetpgrp()*メソッドの構文です-
os.tcgetpgrp(fd)
パラメーター
- fd -これはファイル記述子です。
戻り値
このメソッドはプロセスグループを返します。
例
次の例は、tcgetpgrp()メソッドの使用法を示しています。
# !/usr/bin/python
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
os.close(fd)
print "Closed the file successfully!!"
上記のプログラムを実行すると、次の結果が生成されます-
Current working dir is :/tmp
the process group associated is:
2670
Closed the file successfully!!