* 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.
This commit is contained in:
parent
17133a85de
commit
26b070c0cf
|
@ -1,3 +1,22 @@
|
|||
2011-01-19 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* 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.
|
||||
|
||||
2011-01-19 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* exec.cc (strccpy): Move function from here...
|
||||
|
|
|
@ -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,22 +18,6 @@ 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[])
|
||||
{
|
||||
static char *const empty_env[] = { 0 };
|
||||
MALLOC_CHECK;
|
||||
if (!envp)
|
||||
envp = empty_env;
|
||||
return spawnve (_P_OVERLAY, path, argv, envp);
|
||||
}
|
||||
|
||||
EXPORT_ALIAS (execve, _execve)
|
||||
|
||||
extern "C" int
|
||||
execl (const char *path, const char *arg0, ...)
|
||||
|
@ -51,42 +34,82 @@ 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, path, (char * const *) argv, cur_environ ());
|
||||
}
|
||||
|
||||
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
|
||||
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;
|
||||
i = 1;
|
||||
do
|
||||
argv[i] = va_arg (args, const char *);
|
||||
while (argv[i++] != NULL);
|
||||
va_end (args);
|
||||
MALLOC_CHECK;
|
||||
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 ());
|
||||
}
|
||||
|
||||
extern "C" pid_t
|
||||
sexecve_is_bad ()
|
||||
{
|
||||
set_errno (ENOSYS);
|
||||
return 0;
|
||||
return spawnve (_P_OVERLAY, path, argv, cur_environ ());
|
||||
}
|
||||
|
||||
extern "C" int
|
||||
execvp (const char *path, char * const *argv)
|
||||
execve (const char *path, char *const argv[], char *const envp[])
|
||||
{
|
||||
MALLOC_CHECK;
|
||||
return spawnve (_P_OVERLAY, path, argv, envp);
|
||||
}
|
||||
|
||||
extern "C" int
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue