On this page
os.close
Prev: os.chown | Up: os | Next: os.cpu_count
Rel: os.abort, os.access, os.chdir, os.chmod
Ref: docs.python.org — os.close
Tags: #public #python3 #stdlib #os
Import
import os
from os import close
Signature & Overview
os.close(fd)
Close a file descriptor.
Usage
import os
r_fd, w_fd = os.pipe()
os.close(r_fd)
os.close(w_fd)
Gotchas
- Operates on raw integer file descriptors (
int), not file objects: Closing an already-closed fd raisesOSError(EBADF), and double-closing in multi-threaded code can close another thread's newly opened fd.
REPL Inspect
from os import close
help(close)
Linked from
Related notes
- tuts/python3/stdlib_module/os/chown Linked here; links to this page; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/cpu_count Linked here; links to this page; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/os/abort Linked here; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/access Linked here; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/chdir Linked here; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/chmod Linked here; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/DirEntry shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/dup shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/dup2 shared tags: #os, #stdlib