1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2024-09-16 09:50:21 -04:00

Make sure we have an execvpe on Windows too

Necessary to fix a build (that was already broken in other ways) after
PR #11021.
This commit is contained in:
John Ericson 2024-08-26 15:42:09 -04:00
parent 88998fae74
commit dbabfc92d4
5 changed files with 20 additions and 5 deletions

View file

@ -1,5 +1,7 @@
#pragma once
#include "os-string.hh"
namespace nix {
/**
@ -8,6 +10,9 @@ namespace nix {
*
* We use our own implementation unconditionally for consistency.
*/
int execvpe(const char * file0, char * const argv[], char * const envp[]);
int execvpe(
const OsString::value_type * file0,
const OsString::value_type * const argv[],
const OsString::value_type * const envp[]);
}

View file

@ -129,6 +129,7 @@ sources = files(
'english.cc',
'environment-variables.cc',
'error.cc',
'exec.hh',
'executable-path.cc',
'exit.cc',
'experimental-features.cc',

View file

@ -13,7 +13,6 @@ sources += files(
include_dirs += include_directories('.')
headers += files(
'exec.hh',
'monitor-fd.hh',
'signals-impl.hh',
)

View file

@ -420,10 +420,12 @@ bool statusOk(int status)
return WIFEXITED(status) && WEXITSTATUS(status) == 0;
}
int execvpe(const char * file0, char * const argv[], char * const envp[])
int execvpe(const char * file0, const char * const argv[], const char * const envp[])
{
auto file = ExecutablePath::load().findPath(file0).string();
return execve(file.c_str(), argv, envp);
auto file = ExecutablePath::load().findPath(file0);
// `const_cast` is safe. See the note in
// https://pubs.opengroup.org/onlinepubs/9799919799/functions/exec.html
return execve(file.c_str(), const_cast<char *const *>(argv), const_cast<char *const *>(envp));
}
}

View file

@ -1,6 +1,7 @@
#include "current-process.hh"
#include "environment-variables.hh"
#include "error.hh"
#include "executable-path.hh"
#include "file-descriptor.hh"
#include "file-path.hh"
#include "signals.hh"
@ -377,4 +378,11 @@ bool statusOk(int status)
{
return status == 0;
}
int execvpe(const wchar_t * file0, const wchar_t * const argv[], const wchar_t * const envp[])
{
auto file = ExecutablePath::load().findPath(file0);
return _wexecve(file.c_str(), argv, envp);
}
}