function fork_and_execve_default()

in src/os/_Private/spawn.php [29:53]


function fork_and_execve_default(
  string $path,
  vec<string> $argv,
  vec<string> $envp,
  dict<int, OS\FileDescriptor> $fds,
  _OS\ForkAndExecveOptions $options,
): int {
  if (C\every(STD_FILENOS, $std_fileno ==> C\contains_key($fds, $std_fileno))) {
    // Don't open /dev/null because all standard file numbers are specified
    return _OS\fork_and_execve($path, $argv, $envp, $fds, $options);
  }

  $dev_null_fd = _OS\open('/dev/null', O_RDWR);
  try {
    return _OS\fork_and_execve(
      $path,
      $argv,
      $envp,
      Dict\merge(Dict\fill_keys(STD_FILENOS, $dev_null_fd), $fds),
      $options,
    );
  } finally {
    _OS\close($dev_null_fd);
  }
}