28.10.2021 Views

Python Tutorial ( PDFDrive )

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Description

The method tcgetpgrp() returns the process group associated with the terminal given by fd (an open file

descriptor as returned by os.open())

Syntax

Following is the syntax for tcgetpgrp() method:

os.tcgetpgrp(fd)

Parameters

• fd -- This is the file descriptor.

Return Value

This method returns the process group.

Example

The following example shows the usage of tcgetpgrp() method.

# !/usr/bin/python

import os, sys

# Showing current directory

print "Current working dir :%s" %os.getcwd()

# Changing dir to /dev/tty

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

f = os.tcgetpgrp(fd)

# Showing the process group

print "the process group associated is: "

print f

os.close(fd)

print "Closed the file successfully!!"

Let us compile and run the above program, this will produce the following result:

Current working dir is :/tmp

the process group associated is:

2670

Closed the file successfully!!

os.tcsetpgrp(fd, pg)

Description

The method tcsetpgrp() sets the process group associated with the terminal given by fd (an open file descriptor

as returned by os.open()) to pg.

TUTORIALS POINT

Simply Easy Learning

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!