On this page
os.fork
Prev: os.fdopen | Up: os | Next: os.fsdecode
Rel: os.abort, os.access, os.chdir, os.chmod
Ref: docs.python.org — os.fork
Tags: #public #python3 #stdlib #os
Import
import os
from os import fork
Signature & Overview
os.fork()
Fork a child process.
Usage
import os
# Unix-only process creation; prefer subprocess or multiprocessing in application code
assert hasattr(os, "fork") or os.name == "nt"
Gotchas
- Unsafe in multi-threaded processes: Only the calling thread survives in the child, so held locks can deadlock—prefer
subprocessormultiprocessingwith"spawn".
REPL Inspect
from os import fork
help(fork)
Linked from
Related notes
- tuts/python3/stdlib_module/os/fdopen Linked here; links to this page; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/fsdecode 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/chown shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/close shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/cpu_count shared tags: #os, #stdlib