in src/os/spawn.php [84:107]
protected function forkAndExecveDecorator(
_OS\TForkAndExecve $fork_and_execve,
): _OS\TForkAndExecve {
return ($path, $argv, $envp, $fds, $options) ==> {
$new_cwd =
_File\relative_path($this->path, Shapes::idx($options, 'cwd'));
$canonicalized_new_cwd = \realpath($new_cwd);
if ($canonicalized_new_cwd === false) {
_OS\throw_errno(OS\Errno::ENOENT, '%s does not exist', $new_cwd);
} else {
$canonicalized_new_cwd as string;
if (\is_dir($canonicalized_new_cwd)) {
$options['cwd'] = $canonicalized_new_cwd;
} else {
_OS\throw_errno(
OS\Errno::ENOTDIR,
'%s is not a directory',
$canonicalized_new_cwd,
);
}
}
return $fork_and_execve($path, $argv, $envp, $fds, $options);
};
}