Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More pipes? #75

Open
LacticWhale opened this issue Sep 30, 2024 · 4 comments
Open

More pipes? #75

LacticWhale opened this issue Sep 30, 2024 · 4 comments

Comments

@LacticWhale
Copy link

Is there a way to open more pipes? In normal PHP I can use proc_open to do something like this:

$descriptors = array(
    0 => array("pipe", "r"),  // STDIN
    1 => array("pipe", "w"),  // STDOUT
    2 => array("pipe", "w"),  // STDERR
    3 => array("pipe", "w"),  // DATA
);
$proc = proc_open("data_handler", $descriptors, $pipes, "../../../submodules/data_handler/program");
foreach ($inputs as $input) 
    fwrite($pipes[0], $input.PHP_EOL);
fclose($pipes[0]);

$data   = stream_get_contents($pipes[3]); fclose($pipes[3]);
$stderr = stream_get_contents($pipes[2]); fclose($pipes[2]);
$stdout = stream_get_contents($pipes[1]); fclose($pipes[1]);
$exitCode = proc_close($proc);

I couldn't find any documentation on this.

@kelunik
Copy link
Member

kelunik commented Oct 1, 2024

Currently this is not supported. What are you trying to do?

@LacticWhale
Copy link
Author

LacticWhale commented Oct 1, 2024

What are you trying to do?

I just had a program which used stdout for debug info and an additional pipe for data transfer. It's not a big problem I can move info to stderr and use stdout for data.
But it would be nice to have support for this in the future.

@kelunik
Copy link
Member

kelunik commented Oct 1, 2024

If you control both sides, you might find the IPC API of amphp/parallel helpful: https://github.com/amphp/parallel?tab=readme-ov-file#ipc

@LacticWhale
Copy link
Author

I use it to run programs written in different languages (python, dart). I just did:

list($command, $id, $data) = explode(':', $chunk);

Instead of using different pipes. I guess I could have done this from begining.

But still I think it might be useful to get support for pipes in future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants