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