PyDocs

Nav

Generic Operating System Services

fork

os

functionPOSIXnot WASInot Androidnot iOS
  • fork()
Fork a child process.

Return 0 to child process and PID of child to parent process.
Changed in 3.8, 3.12
  • 3.8: Calling fork() in a subinterpreter is no longer supported (RuntimeError is raised).
  • 3.12: If Python is able to detect that your process has multiple threads, os.fork() now raises a DeprecationWarning. We chose to surface this as a warning, when detectable, to better inform developers of a design problem that the POSIX platform specifically notes as not supported. Even in code that appears to work, it has never been safe to mix threading with os.fork() on POSIX platforms. The CPython runtime itself has always made API calls that are not safe for use in the child process when threads existed in the parent (such as malloc and free). Users of macOS or users of libc or malloc implementations other than those typically found in glibc to date are among those already more likely to experience deadlocks running such code. See this discussion on fork being incompatible with threads for technical details of why we’re surfacing this longstanding platform compatibility problem to developers.
0 Examples
No examples for os/fork.
See Also
No see-alsos for os/fork
0 Notes
No notes for fork