當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python 3 os.tcsetpgrp()用法及代碼示例


描述

方法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!!")

結果

當我們運行上述程序時,它會產生以下結果 -

Current working dir is:/tmp
the process group associated is:
2672
done
Closed the file successfully!!

相關用法


注:本文由純淨天空篩選整理自 Python 3 - os.tcsetpgrp() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。