Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python os.tcgetpgrp() method

Python os.tcgetpgrp() method

Python File methods Python OS file/directory methods


Overview

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

Syntax

The **tcgetpgrp()** method syntax is as follows:



os.tcgetpgrp(fd)

Parameters

Return Value

This method returns the process group.

Example

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



#!/usr/bin/python

# -*- coding: UTF-8 -*-



import os, sys



# Show current directory

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



# Change directory to /dev/tty

fd = os.open("/dev/tty",os.O_RDONLY)



f = os.tcgetpgrp(fd)



# Show process group

print "相关进程组: "

print f



os.close(fd)

print "关闭文件成功!!"

The output of the above program is:

当前目录 :/tmp

Related process groups:

2670

关闭文件成功!!

Python File methods Python OS file/directory methods