-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add better detached mode support for Windows
- Loading branch information
Showing
1 changed file
with
18 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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)); | ||
|
@@ -270,6 +285,8 @@ private function determineRuntimeMode() | |
$functions = array('shell_exec'); | ||
if (!defined('PHP_WINDOWS_VERSION_BUILD')) { | ||
$functions[] = 'posix_kill'; | ||
} else { | ||
$functions[] = 'proc_open'; | ||
} | ||
} | ||
|
||
|