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/exec.cc | |
parent | 17133a85de3326ec7c63f800581984392ddd276f (diff) | |
download | newlib-26b070c0cf8948c40bb8d09bfff318b6efbcec5c.zip newlib-26b070c0cf8948c40bb8d09bfff318b6efbcec5c.tar.gz newlib-26b070c0cf8948c40bb8d09bfff318b6efbcec5c.tar.bz2 |
* 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/exec.cc')
-rw-r--r-- | winsup/cygwin/exec.cc | 86 |
1 files changed, 59 insertions, 27 deletions
diff --git a/winsup/cygwin/exec.cc b/winsup/cygwin/exec.cc index 327e86a..4ca232c 100644 --- a/winsup/cygwin/exec.cc +++ b/winsup/cygwin/exec.cc @@ -8,7 +8,6 @@ This software is a copyrighted work licensed under the terms of the Cygwin license. Please consult the file "CYGWIN_LICENSE" for details. */ -#define _execve __FOO_execve_ #include "winsup.h" #include <process.h> #include "cygerrno.h" @@ -19,29 +18,52 @@ details. */ #include "dtable.h" #include "cygheap.h" #include "winf.h" -#undef _execve - -/* This is called _execve and not execve because the real execve is defined - in libc/posix/execve.c. It calls us. */ extern "C" int -execve (const char *path, char *const argv[], char *const envp[]) +execl (const char *path, const char *arg0, ...) { - static char *const empty_env[] = { 0 }; + int i; + va_list args; + const char *argv[1024]; + + va_start (args, arg0); + argv[0] = arg0; + i = 1; + do + argv[i] = va_arg (args, const char *); + while (argv[i++] != NULL); + va_end (args); MALLOC_CHECK; - if (!envp) - envp = empty_env; - return spawnve (_P_OVERLAY, path, argv, envp); + return spawnve (_P_OVERLAY, path, (char * const *) argv, cur_environ ()); } -EXPORT_ALIAS (execve, _execve) +extern "C" int +execle (const char *path, const char *arg0, ...) +{ + int i; + va_list args; + const char *argv[1024]; + const char * const *envp; + + va_start (args, arg0); + argv[0] = arg0; + i = 1; + do + argv[i] = va_arg (args, const char *); + while (argv[i++] != NULL); + envp = va_arg (args, const char * const *); + va_end (args); + MALLOC_CHECK; + return spawnve (_P_OVERLAY, path, (char * const *) argv, envp); +} extern "C" int -execl (const char *path, const char *arg0, ...) +execlp (const char *file, const char *arg0, ...) { int i; va_list args; const char *argv[1024]; + path_conv buf; va_start (args, arg0); argv[0] = arg0; @@ -51,42 +73,43 @@ execl (const char *path, const char *arg0, ...) while (argv[i++] != NULL); va_end (args); MALLOC_CHECK; - return execve (path, (char * const *) argv, cur_environ ()); + return spawnve (_P_OVERLAY, find_exec (file, buf, "PATH=", FE_NNF) ?: "", + (char * const *) argv, cur_environ ()); } extern "C" int execv (const char *path, char * const *argv) { MALLOC_CHECK; - return execve (path, (char * const *) argv, cur_environ ()); + return spawnve (_P_OVERLAY, path, argv, cur_environ ()); } -extern "C" pid_t -sexecve_is_bad () +extern "C" int +execve (const char *path, char *const argv[], char *const envp[]) { - set_errno (ENOSYS); - return 0; + MALLOC_CHECK; + return spawnve (_P_OVERLAY, path, argv, envp); } extern "C" int -execvp (const char *path, char * const *argv) +execvp (const char *file, char * const *argv) { path_conv buf; + + MALLOC_CHECK; return spawnve (_P_OVERLAY | _P_PATH_TYPE_EXEC, - find_exec (path, buf, "PATH=", FE_NNF) ?: "", + find_exec (file, buf, "PATH=", FE_NNF) ?: "", argv, cur_environ ()); } extern "C" int -execvpe (const char *path, char * const *argv, char *const *envp) +execvpe (const char *file, char * const *argv, char *const *envp) { - static char *const empty_env[] = { 0 }; - MALLOC_CHECK; - if (!envp) - envp = empty_env; path_conv buf; + + MALLOC_CHECK; return spawnve (_P_OVERLAY | _P_PATH_TYPE_EXEC, - find_exec (path, buf, "PATH=", FE_NNF) ?: "", + find_exec (file, buf, "PATH=", FE_NNF) ?: "", argv, envp); } @@ -99,5 +122,14 @@ fexecve (int fd, char * const *argv, char *const *envp) syscall_printf ("-1 = fexecve (%d, %p, %p)", fd, argv, envp); return -1; } - return execve (cfd->pc.get_win32 (), argv, envp); + + MALLOC_CHECK; + return spawnve (_P_OVERLAY, cfd->pc.get_win32 (), argv, envp); +} + +extern "C" pid_t +sexecve_is_bad () +{ + set_errno (ENOSYS); + return 0; } |