Python3-os-tcgetpgrp
提供:Dev Guides
Python 3-os.tcgetpgrp()メソッド
説明
- tcgetpgrp()メソッドは、 *fd (link:/python3/os_open [os.open()]によって返されるオープンファイル記述子)によって指定された端末に関連付けられたプロセスグループを返します。
構文
以下は、* tcgetpgrp()*メソッドの構文です-
os.tcgetpgrp(fd)
パラメーター
*fd* -これはファイル記述子です。
戻り値
このメソッドはプロセスグループを返します。
例
次の例は、tcgetpgrp()メソッドの使用法を示しています。
# !/usr/bin/python3
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!!