1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-04 07:11:47 +02: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,13 +0,0 @@
#pragma once
namespace nix {
/**
* `execvpe` is a GNU extension, so we need to implement it for other POSIX
* platforms.
*
* We use our own implementation unconditionally for consistency.
*/
int execvpe(const char * file0, char * const argv[], char * const envp[]);
}

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));
}
}