Python的tcsetpgrp()
方法將與fd
(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!!")
當運行上述程式時,它將在/tmp
目錄中創建一個符號鏈接,如下所示: -
Current working dir is :/tmp
the process group associated is:
2672
done
Closed the file successfully!!
上一篇:
Python os模組方法
下一篇:
Python異常處理