1

I'm currently using the ReactPHP Child-Process library (which uses proc_open()) to get data from a Go application in stream format. However, when I dump all input from stdout and stderr, I get nothing even though when I test it in bash I get output.

Here is the Go script: https://github.com/bwmarrin/dca/blob/master/main.go

The Go script uses goroutines so that may be the issue? (Not sure, I'm not a Go developer and I didn't make the program.)

I'm running on Mac OS X 10.11.2 El Capitan with PHP 7.0.3 CLI.

PHP Code:

$loop = Factory::create();

$process = new Process("dca -i /Users/david/Music/Zombies.mp3");

$process->start($loop);
$process->stdout->on('data', function ($data) {
    var_dump($data);
});
$process->stderr->on('data', function ($data) {
    dump($data);
});

$loop->run();

React Child-Process can be found here: https://github.com/reactphp/child-process

cheese5505
  • 962
  • 5
  • 14
  • 30
  • Post php code related to the question please. – dezhik Feb 12 '16 at 08:48
  • @dezhik thanks, added – cheese5505 Feb 12 '16 at 08:52
  • It is not related to the use of goroutines. As this programs works with unix pipes specifically, you might need to attach the process to a shell instead of running it directly. – thwd Feb 12 '16 at 12:51
  • Does the program output when you run it directly on the command line? There doesn't appear to be anything broken with the Go code. Besides that `dump()` is not a built-in PHP function, so are you certain that function is doing what you expect? – Sean Feb 12 '16 at 20:59
  • @Sean Yeah, it works fine in the command line. `dump()` is just a function that comes with `symfony/var-dumper`. – cheese5505 Feb 12 '16 at 21:31
  • @thwd Pretty new to using that stuff haha, how would I attach the process to a shell? – cheese5505 Feb 12 '16 at 21:48
  • My next recommendation would be making sure your path is correct. So instead of assuming that the application has the correct PATH, try putting in the full path. ex. `/usr/local/bin`. If you don't know what it is just use `which dca` to find it. – Sean Feb 12 '16 at 22:00
  • @thwd sorry for the bump, i still haven't got it working and was wondering if you would be able to help me to "attach the process to a shell"? – cheese5505 Feb 19 '16 at 04:20
  • @cheese5505 no problem, for example `new Process("bash -c 'dca -i /Users/david/Music/Zombies.mp3'");` – thwd Feb 19 '16 at 09:02
  • @thwd still the same problem :( – cheese5505 Feb 20 '16 at 01:06

0 Answers0