Python os.tcsetpgrp() Method

Python File(文件) 方法Python OS File/Directory Methods


Overview

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

Syntax

tcsetpgrp()The method syntax is as follows:

os.tcsetpgrp(fd, pg)

Parameters

  • fd-- file descriptor.

  • pg-- associated process group.

Return Value

This method does not return a value.

Example

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

#!/usr/bin/python
# -*- coding: UTF-8 -*-

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.tcsetpgrp(fd,2672)
print "done"

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

The output of the above program is:

当前目录 :/tmp
关联进程组:
2672
done
关闭文件成功!!

Python File(文件) 方法Python OS File/Directory Methods

Other Extensions