mirror of
https://github.com/danog/process.git
synced 2024-11-30 04:39:04 +01:00
Copy wrapper exe outside the archive on Windows in case of PHARs
This commit is contained in:
parent
e0c753c53b
commit
b795d20a7f
@ -29,12 +29,30 @@ final class Runner implements ProcessRunner {
|
|||||||
? BIN_DIR . '\\windows\\ProcessWrapper64.exe'
|
? BIN_DIR . '\\windows\\ProcessWrapper64.exe'
|
||||||
: BIN_DIR . '\\windows\\ProcessWrapper.exe';
|
: BIN_DIR . '\\windows\\ProcessWrapper.exe';
|
||||||
|
|
||||||
|
private static $pharWrapperPath;
|
||||||
|
|
||||||
private $socketConnector;
|
private $socketConnector;
|
||||||
|
|
||||||
private function makeCommand(string $workingDirectory): string {
|
private function makeCommand(string $workingDirectory): string {
|
||||||
|
$wrapperPath = self::WRAPPER_EXE_PATH;
|
||||||
|
|
||||||
|
// We can't execute the exe from within the PHAR, so copy it out...
|
||||||
|
if (strncmp($wrapperPath, "phar://", 7) === 0) {
|
||||||
|
if (self::$pharWrapperPath === null) {
|
||||||
|
self::$pharWrapperPath = \tempnam(\sys_get_temp_dir(), "amphp-process-wrapper-");
|
||||||
|
\copy(self::WRAPPER_EXE_PATH, self::$pharWrapperPath);
|
||||||
|
|
||||||
|
\register_shutdown_function(static function () {
|
||||||
|
@\unlink(self::$pharWrapperPath);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$wrapperPath = self::$pharWrapperPath;
|
||||||
|
}
|
||||||
|
|
||||||
$result = \sprintf(
|
$result = \sprintf(
|
||||||
'%s --address=%s --port=%d --token-size=%d',
|
'%s --address=%s --port=%d --token-size=%d',
|
||||||
\escapeshellarg(self::WRAPPER_EXE_PATH),
|
\escapeshellarg($wrapperPath),
|
||||||
$this->socketConnector->address,
|
$this->socketConnector->address,
|
||||||
$this->socketConnector->port,
|
$this->socketConnector->port,
|
||||||
SocketConnector::SECURITY_TOKEN_SIZE
|
SocketConnector::SECURITY_TOKEN_SIZE
|
||||||
|
Loading…
Reference in New Issue
Block a user