Skip to content

Commit

Permalink
add better detached mode support for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
fritzmg authored and fritzmg committed Jan 31, 2017
1 parent a95b164 commit 6e24351
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* @copyright ContaoCommunityAlliance 2013
* @author Christian Schiffler <[email protected]>
* @author Tristan Lins <[email protected]>
* @author Fritz Michael Gschwantner <[email protected]>
* @package Composer
* @license LGPLv3
* @filesource
Expand Down Expand Up @@ -240,7 +241,21 @@ protected function runDetached($packages, $dryRun)
escapeshellarg(TL_ROOT . '/' . DetachedController::OUT_FILE_PATHNAME)
);

$processId = shell_exec($cmd);
if (substr(php_uname(), 0, 7) == "Windows") {
$proc = proc_open(
$cmd,
array(
array('pipe', 'r'),
array('pipe', 'w'),
array('pipe', 'w')
),
$pipes
);
$procStatus = proc_get_status($proc);
$processId = $procStatus['pid'];
} else {
$processId = shell_exec($cmd);
}

$pidFile = new \File(DetachedController::PID_FILE_PATHNAME);
$pidFile->write(trim($processId));
Expand Down Expand Up @@ -270,6 +285,8 @@ private function determineRuntimeMode()
$functions = array('shell_exec');
if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
$functions[] = 'posix_kill';
} else {
$functions[] = 'proc_open';
}
}

Expand Down

0 comments on commit 6e24351

Please sign in to comment.