Python program using os.pipe and os.fork() issue

后端 未结 4 781
花落未央
花落未央 2020-12-14 12:07

I\'ve recently needed to write a script that performs an os.fork() to split into two processes. The child process becomes a server process and passes data b

4条回答
  •  渐次进展
    2020-12-14 12:28

    The "parent" vs. "child" part of fork in a Python application is silly. It's a legacy from 16-bit unix days. It's an affectation from a day when fork/exec and exec were Important Things to make the most of a tiny little processor.

    Break your Python code into two separate parts: parent and child.

    The parent part should use subprocess to run the child part.

    A fork and exec may happen somewhere in there -- but you don't need to care.

提交回复
热议问题