diff options
author | tv <tv@krebsco.de> | 2018-09-16 01:44:08 +0200 |
---|---|---|
committer | tv <tv@krebsco.de> | 2018-09-16 01:44:08 +0200 |
commit | c27a9416e8ee04d708b11b48f8cf1a055c0cc079 (patch) | |
tree | e1f7f236ba12267c89125d6b5d89c2e357193a2d /pkgs | |
parent | f765bef6beb3c9a7275d5171e6c9029b4f7a494e (diff) |
pkgs: execve -> execv3.0.0palo/master
Diffstat (limited to 'pkgs')
-rw-r--r-- | pkgs/default.nix | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/pkgs/default.nix b/pkgs/default.nix index 29457ca..a5582f3 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -1,7 +1,7 @@ with import ../lib; pkgs: oldpkgs: { - execve = name: { filename, argv ? null, envp ? {}, destination ? "" }: + exec = name: { filename, argv ? null, envp ? null, destination ? "" }: pkgs.writeC name { inherit destination; } /* c */ '' #include <unistd.h> @@ -16,18 +16,24 @@ pkgs: oldpkgs: { static char *const argv[] = ${toC (argv ++ [null])}; ''} - static char *const envp[] = ${toC ( - mapAttrsToList (k: v: "${k}=${v}") envp ++ [null] - )}; + ${optionalString (envp != null) /* c */ '' + static char *const envp[] = ${toC ( + mapAttrsToList (k: v: "${k}=${v}") envp ++ [null] + )}; + ''} int main (MAIN_ARGS) { - execve(filename, argv, envp); + ${if envp == null then /* c */ '' + execv(filename, argv); + '' else /* c */ '' + execve(filename, argv, envp); + ''} return -1; } ''; - execveBin = name: cfg: - pkgs.execve name (cfg // { destination = "/bin/${name}"; }); + execBin = name: cfg: + pkgs.exec name (cfg // { destination = "/bin/${name}"; }); makeScriptWriter = { interpreter, check ? null }: name: text: assert (with types; either absolute-pathname filename).check name; |