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