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

Python os.tcsetpgrp() method

Python os.tcsetpgrp() method

Python File methods Python OS file/directory methods


Overview

The os.tcsetpgrp() method sets the process group associated with the terminal fd (an open file descriptor returned by os.open()) to pg.

Syntax

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



os.tcsetpgrp(fd, pg)

Parameters

Return Value

This method has no return value.

Example

The following example demonstrates the use of the tcsetpgrp() 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



# Set process group

os.tcsetpgrp(fd,2672)

print "done"



os.close(fd)

print "关闭文件成功!!"

The output of the above program is:



当前目录 :/tmp

Associate process group:

2672

done

关闭文件成功!!

Python File methods Python OS file/directory methods