OS File 中的 os.tcgetpgrp(fd)函数

首页 / Python2入门教程 / OS File 中的 os.tcgetpgrp(fd)函数

Python方法tcgetpgrp()返回与fd给定的终端相关联的进程组(由os.open()返回的打开文件描述符)

os.tcgetpgrp(fd) - 语法

os.tcgetpgrp(fd)
  • fd  -  这是文件描述符。

os.tcgetpgrp(fd) - 返回值

此方法返回进程组。

无涯教程网

os.tcgetpgrp(fd) - 示例

以下示例显示tcgetpgrp()方法的用法。

# !/usr/bin/python

import os, sys

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

# 将目录更改为 /dev/tty
fd=os.open("/dev/tty",os.O_RDONLY)

f=os.tcgetpgrp(fd)

# 显示进程组
print "the process group associated is: "
print f

os.close(fd)
print "Closed the file successfully!!"

当无涯教程运行上面的程序时,它产生以下输出-

Current working dir is :/tmp
the process group associated is:
2670
Closed the file successfully!!

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

深入浅出gRPC -〔李林锋〕

深入拆解Java虚拟机 -〔郑雨迪〕

Linux内核技术实战课 -〔邵亚方〕

动态规划面试宝典 -〔卢誉声〕

零基础入门Spark -〔吴磊〕

快手 · 移动端音视频开发实战 -〔展晓凯〕

Dubbo源码剖析与实战 -〔何辉〕

结构思考力 · 透过结构看表达 -〔李忠秋〕

PPT设计进阶 · 从基础操作到高级创意 -〔李金宝(Bobbie)〕

好记忆不如烂笔头。留下您的足迹吧 :)