Python3 os.tcgetpgrp() Method

Python3 OS 文件/目录方法Python3 OS File/Directory Methods


Overview

The os.tcgetpgrp() method is used to return the process group associated with the terminal fd (an open file descriptor returned by os.open()).

Syntax

tcgetpgrp()The method syntax is as follows:

os.tcgetpgrp(fd)

Parameters

  • fd-- File descriptor.

Return Value

This method returns the process group.

Example

The following example demonstrates the use of the tcgetpgrp() method:

#!/usr/bin/python3

import os, sys

# 显示当前目录
print ("当前目录 :%s" %os.getcwd())

# 修改目录到 /dev/tty
fd = os.open("/dev/tty",os.O_RDONLY)

f = os.tcgetpgrp(fd)

# 显示进程组
print ("相关进程组: ")
print (f)

os.close(fd)
print ("关闭文件成功!!")

The output of the above program is:

当前目录 :/tmp
相关进程组:
2670
关闭文件成功!!

Python3 OS 文件/目录方法Python3 OS File/Directory Methods

Other Extensions