mirror of
https://github.com/danog/process.git
synced 2024-11-29 20:29:16 +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\\ProcessWrapper.exe';
|
||||
|
||||
private static $pharWrapperPath;
|
||||
|
||||
private $socketConnector;
|
||||
|
||||
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(
|
||||
'%s --address=%s --port=%d --token-size=%d',
|
||||
\escapeshellarg(self::WRAPPER_EXE_PATH),
|
||||
\escapeshellarg($wrapperPath),
|
||||
$this->socketConnector->address,
|
||||
$this->socketConnector->port,
|
||||
SocketConnector::SECURITY_TOKEN_SIZE
|
||||
|
Loading…
Reference in New Issue
Block a user