Skip to content

Commit

Permalink
Add nix::execvpe
Browse files Browse the repository at this point in the history
  • Loading branch information
roberth committed Aug 16, 2024
1 parent 31f3f23 commit c4192a6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/libutil/unix/exec.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#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[]);

}
1 change: 1 addition & 0 deletions src/libutil/unix/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ sources += files(
include_dirs += include_directories('.')

headers += files(
'exec.hh',
'monitor-fd.hh',
'signals-impl.hh',
)
7 changes: 7 additions & 0 deletions src/libutil/unix/processes.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "current-process.hh"
#include "environment-variables.hh"
#include "executable-path.hh"
#include "signals.hh"
#include "processes.hh"
#include "finally.hh"
Expand Down Expand Up @@ -419,4 +420,10 @@ bool statusOk(int status)
return WIFEXITED(status) && WEXITSTATUS(status) == 0;
}

int execvpe(const char * file0, char * const argv[], char * const envp[])
{
auto file = ExecutablePath::load().findPath(file0).string();
return execve(file.c_str(), argv, envp);
}

}

0 comments on commit c4192a6

Please sign in to comment.