diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2011-01-19 10:28:39 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2011-01-19 10:28:39 +0000 |
commit | 26b070c0cf8948c40bb8d09bfff318b6efbcec5c (patch) | |
tree | ddbda395a73ca4645ce6f44a7c339866f33c8063 /winsup/cygwin/spawn.cc | |
parent | 17133a85de3326ec7c63f800581984392ddd276f (diff) | |
download | cygnal-26b070c0cf8948c40bb8d09bfff318b6efbcec5c.tar.gz cygnal-26b070c0cf8948c40bb8d09bfff318b6efbcec5c.tar.bz2 cygnal-26b070c0cf8948c40bb8d09bfff318b6efbcec5c.zip |
* exec.cc: Rearrange functions in alphabetical order.
(_execve): Drop temporary define and drop export alias.
(execl): Call spawnve.
(execle): New function.
(execlp): New function.
(execv): Call spawnve.
(execve): Drop converting NULL envp to emtpy envp.
(execvp): Call spawnve.
(execvpe): Drop converting NULL envp to emtpy envp. Call spawnve.
(fexecve): Call spawnve.
* spawn.cc (spawnve): Convert NULL envp to emtpy envp. Remove outdated
comment.
(spawnlp): Call spawnve.
(spawnlpe): Ditto.
(spawnvp): Ditto.
(spawnvpe): Fix formatting.
Diffstat (limited to 'winsup/cygwin/spawn.cc')
-rw-r--r-- | winsup/cygwin/spawn.cc | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index 90ba65efa..4575d7bb3 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -854,6 +854,8 @@ extern "C" int spawnve (int mode, const char *path, const char *const *argv, const char *const *envp) { + static char *const empty_env[] = { NULL }; + int ret; #ifdef NEWVFORK vfork_save *vf = vfork_storage.val (); @@ -866,11 +868,12 @@ spawnve (int mode, const char *path, const char *const *argv, syscall_printf ("spawnve (%s, %s, %x)", path, argv[0], envp); + if (!envp) + envp = empty_env; + switch (_P_MODE (mode)) { case _P_OVERLAY: - /* We do not pass _P_SEARCH_PATH here. execve doesn't search PATH.*/ - /* Just act as an exec if _P_OVERLAY set. */ spawn_guts (path, argv, envp, mode); /* Errno should be set by spawn_guts. */ ret = -1; @@ -949,11 +952,12 @@ spawnle (int mode, const char *path, const char *arg0, ...) } extern "C" int -spawnlp (int mode, const char *path, const char *arg0, ...) +spawnlp (int mode, const char *file, const char *arg0, ...) { int i; va_list args; const char *argv[256]; + path_conv buf; va_start (args, arg0); argv[0] = arg0; @@ -965,16 +969,18 @@ spawnlp (int mode, const char *path, const char *arg0, ...) va_end (args); - return spawnvpe (mode, path, (char * const *) argv, cur_environ ()); + return spawnve (mode, find_exec (file, buf), (char * const *) argv, + cur_environ ()); } extern "C" int -spawnlpe (int mode, const char *path, const char *arg0, ...) +spawnlpe (int mode, const char *file, const char *arg0, ...) { int i; va_list args; const char * const *envp; const char *argv[256]; + path_conv buf; va_start (args, arg0); argv[0] = arg0; @@ -987,7 +993,7 @@ spawnlpe (int mode, const char *path, const char *arg0, ...) envp = va_arg (args, const char * const *); va_end (args); - return spawnvpe (mode, path, (char * const *) argv, envp); + return spawnve (mode, find_exec (file, buf), (char * const *) argv, envp); } extern "C" int @@ -997,14 +1003,15 @@ spawnv (int mode, const char *path, const char * const *argv) } extern "C" int -spawnvp (int mode, const char *path, const char * const *argv) +spawnvp (int mode, const char *file, const char * const *argv) { - return spawnvpe (mode, path, argv, cur_environ ()); + path_conv buf; + return spawnve (mode, find_exec (file, buf), argv, cur_environ ()); } extern "C" int spawnvpe (int mode, const char *file, const char * const *argv, - const char * const *envp) + const char * const *envp) { path_conv buf; return spawnve (mode | _P_PATH_TYPE_EXEC, find_exec (file, buf), argv, envp); |