Easy Tutorial
❮ Python Cgi Programming Python Counting Sort ❯

Python3 os.tcsetpgrp() Method

Python3 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

The syntax for the tcsetpgrp() method is as follows:

os.tcsetpgrp(fd, pg)

Parameters

-

fd -- File descriptor.

-

pg -- Associated process group.

Return Value

This method does not return any value.

Example

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

#!/usr/bin/python3

import os, sys

# Display current directory
print("Current directory :%s" % os.getcwd())

# Change directory to /dev/tty
fd = os.open("/dev/tty", os.O_RDONLY)

f = os.tcgetpgrp(fd)

# Display process group
print("Associated process group: ")
print(f)

# Set process group
os.tcsetpgrp(fd, 2672)
print("done")

os.close(fd)
print("File closed successfully!!")

Output of the above program is:

Current directory :/tmp
Associated process group:
2672
done
File closed successfully!!

Python3 OS File/Directory Methods

❮ Python Cgi Programming Python Counting Sort ❯