Latest web development tutorials

Python os.tcsetpgrp () method

Python File (File) method Python OS file / directory methods


Outline

Process group os.tcsetpgrp () method is used to set the terminal fd (consisting os.open returned () open file descriptors) associated to pg.

grammar

tcsetpgrp () method syntax is as follows:

os.tcsetpgrp(fd, pg)

parameter

  • fd - file descriptor.

  • pg - process associated with the group.

return value

This method has no return value.

Examples

The following example demonstrates tcsetpgrp () method of use:

#!/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 above program output is:

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

Python File (File) method Python OS file / directory methods