Skip to content

Make child process InheritFd by default #755

@m13253

Description

@m13253

In the current design of std::io::process, three sets of pipes are created for the child process: std{in,out,err}.

I submit this issue here, to ask for support to make child process InheritFd by default in the new design, that is, use the parent process's std{in,out,err} instead of pipes.

Reasons:

  • Child processes are InheritFd by default both on POSIX and Windows, with native API. Pipes can be explicitly set up.
  • Pipes are not used so often that it should be the default. At least not all std{in,out,err} are used at the same time that often.
  • It is potential that the programmer forgets to set InheritFd when pipes are unneeded. Which may lead to the child process being locked up, when the child process writes out too much thing but the parent process does not read anything from the pipe.
  • If the parent process terminates, the child process will crash with "broken pipe" when trying to read or write.
  • Inheritance of file descriptors other than 0, 1, 2 are not supported in current design. However, it is useful in many applications (apt-get uses fd 4 to exchange status data between processes), where sockets are inappropriate.
  • Backwards compatibility is not a problem, since we are redesigning std::io completely these days.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions