moteus/NginxWinService

Exec xcopy command.

moteus opened this issue · 0 comments

I am not sure about why but exec('xcopy ...') does not works if pass INVALID_HANDLE as
stdin hadles to php-cgi.exe. Tested on PHP 5.4 and 5.6.
If use php-cgi mode when pass socket as stdin and INVALID_HANDLES as stdout and stderr
is also works. Basic php test script

function my_exec($cmd){
  exec($cmd, $copy_out, $copy_status);
  var_dump($cmd);echo("<br/>\n");
  var_dump($copy_out);echo("<br/>\n");
  var_dump($copy_status);echo("<br/>\n");
  var_dump("*****************************");echo("<br/>\n");
}

my_exec('copy /? 2>&1'); // works in any case
my_exec('xcopy /? 2>&1'); // does not works if pass INVALID_HANDLE as stdin to php-cgi process

Update
Seems php-cgi process pass its own stdin as stdin for child precesse wen it php call exec function.
Some programs do not work when they get invalid stdin.

Found this post