Easy Tutorial
❮ Python Quicksort Python Tuple ❯

Python3 os.tcgetpgrp() Method

Python3 OS File/Directory Methods


Overview

The os.tcgetpgrp() method is used to return the process group associated with the terminal fd (a file descriptor returned by os.open()).

Syntax

tcgetpgrp() method syntax is as follows:

os.tcgetpgrp(fd)

Parameters

-

fd -- File descriptor.

Return Value

This method returns the process group.

Example

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

#!/usr/bin/python3

import os, sys

# Display the 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 the process group
print ("Associated process group: ")
print (f)

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

Executing the above program outputs:

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

Python3 OS File/Directory Methods

❮ Python Quicksort Python Tuple ❯