Python Glossary Русский

Python 3.4+osfunction

os.set_inheritable

os — file descriptors

Set whether a file descriptor is inheritable by child processes.

Syntax

os.set_inheritable(fd, inheritable)

Use it when a child program really needs a descriptor, such as a pipe end. subprocess offers the pass_fds parameter for this, which is handier: the flag is set only for that launch. The flag belongs to the descriptor, not the file: a dup copy has its own.

Examples

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

See also

Open in the full glossarydocs.python.orgReport an inaccuracy