Python Glossary Русский

Python 3.4+osfunction

os.get_inheritable

os — file descriptors

Check whether a file descriptor is inheritable by child processes.

Syntax

os.get_inheritable(fd)

Since Python 3.4 (PEP 446) every descriptor Python creates is non-inheritable by default — a child program will not accidentally get the parent's open files and sockets. The exception is the standard 0, 1 and 2. The function lets you check the flag before launching a program via exec or spawn.

Examples

import os
r, w = os.pipe()
print(isinstance(os.get_inheritable(r), bool))   # → True
os.close(r)
os.close(w)

See also

Common errors

Open in the full glossarydocs.python.orgReport an inaccuracy