Skip to content

Add support for additional file descriptors #12

@vektah

Description

@vektah

In writing https://github.com/Vektah/phpunit-parallel I wanted to set up an additional pipe between the parent and child processes, but it seems there is currently no good way to do this.

We could add it to the constructor, but the constructor already has a bunch of arguments:

/**
    * Constructor.
    *
    * @param string $cmd     Command line to run
    * @param string $cwd     Current working directory or null to inherit
    * @param array  $env     Environment variables or null to inherit
    * @param array  $options Options for proc_open()
    * @throws RuntimeException When proc_open() is not installed
    */
    public function __construct($cmd, $cwd = null, array $env = null, array $options = array())

It really shouldn't be mutable state though otherwise cleanup could be broken and file descriptors could start leaking.

I'm happy to throw a PR up but I want to get some thoughts first.

Block of code in question:

        $fdSpec = array(
            array('pipe', 'r'), // stdin
            array('pipe', 'w'), // stdout
            array('pipe', 'w'), // stderr
            // I want to add additional pipes here. 
        );

enhanced sigchild support will also need to move down the appropriate number of file descriptors when new descriptors are added.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions