Skip to content

Commit

Permalink
chore(shell): use exec to avoid spawning a grandchild process
Browse files Browse the repository at this point in the history
Signed-off-by: azjezz <azjezz@protonmail.com>
  • Loading branch information
azjezz committed Dec 1, 2021
1 parent d9fd48e commit 0153af4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/Psl/Shell/execute.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ static function (array $m) use (
'bypass_shell' => true,
'blocking_pipes' => false,
];
} else {
$commandline = Str\format('exec %s', $commandline);
}
// @codeCoverageIgnoreEnd
$descriptor = [
Expand Down
10 changes: 2 additions & 8 deletions tests/unit/Shell/ExecuteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,10 @@ public function testCurrentEnvironmentVariablesArePassedDownToTheProcess(): void

public function testWorkingDirectoryIsUsed(): void
{
if ('Darwin' === PHP_OS_FAMILY || PHP_OS_FAMILY === 'Windows') {
static::markTestSkipped();
}

$temp = Env\temp_dir();
$result = Shell\execute(PHP_BINARY, ['-r', 'echo getcwd();'], $temp);

static::assertSame(
$temp,
Shell\execute(PHP_BINARY, ['-r', 'echo getcwd();'], $temp)
);
static::assertStringEndsWith($temp, $result);
}

public function testCurrentDirectoryIsUsedByDefault(): void
Expand Down

0 comments on commit 0153af4

Please sign in to comment.