Update.
* posix/execvp.c (execvp): Allocate array name of correct size. Optimize inner loop. Use execve directly, not execv.
This commit is contained in:
parent
f05ce1953c
commit
d13ec59a49
@ -1,5 +1,8 @@
|
|||||||
1999-08-20 Ulrich Drepper <drepper@cygnus.com>
|
1999-08-20 Ulrich Drepper <drepper@cygnus.com>
|
||||||
|
|
||||||
|
* posix/execvp.c (execvp): Allocate array name of correct size.
|
||||||
|
Optimize inner loop. Use execve directly, not execv.
|
||||||
|
|
||||||
* elf/elf.h: Corrected SHT_ values from new draft.
|
* elf/elf.h: Corrected SHT_ values from new draft.
|
||||||
|
|
||||||
1999-08-20 Andreas Schwab <schwab@suse.de>
|
1999-08-20 Andreas Schwab <schwab@suse.de>
|
||||||
|
@ -47,7 +47,7 @@ script_execute (const char *file, char *const argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Execute the shell. */
|
/* Execute the shell. */
|
||||||
execv (new_argv[0], new_argv);
|
__execve (new_argv[0], new_argv, __environ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ execvp (file, argv)
|
|||||||
if (strchr (file, '/') != NULL)
|
if (strchr (file, '/') != NULL)
|
||||||
{
|
{
|
||||||
/* Don't search when it contains a slash. */
|
/* Don't search when it contains a slash. */
|
||||||
execv (file, argv);
|
__execve (file, argv, __environ);
|
||||||
|
|
||||||
if (errno == ENOEXEC)
|
if (errno == ENOEXEC)
|
||||||
script_execute (file, argv);
|
script_execute (file, argv);
|
||||||
@ -93,30 +93,32 @@ execvp (file, argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
len = strlen (file) + 1;
|
len = strlen (file) + 1;
|
||||||
name = __alloca (strlen (path) + len);
|
name = __alloca (strlen (path) + len + 1);
|
||||||
|
/* Copy the file name at the top. */
|
||||||
|
name = (char *) memcpy (name - len, file, len);
|
||||||
|
/* And add the slash. */
|
||||||
|
*--name = '/';
|
||||||
|
|
||||||
p = path;
|
p = path;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
char *startp;
|
||||||
|
|
||||||
path = p;
|
path = p;
|
||||||
p = __strchrnul (path, ':');
|
p = __strchrnul (path, ':');
|
||||||
|
|
||||||
if (p == path)
|
if (p == path)
|
||||||
/* Two adjacent colons, or a colon at the beginning or the end
|
/* Two adjacent colons, or a colon at the beginning or the end
|
||||||
of `PATH' means to search the current directory. */
|
of `PATH' means to search the current directory. */
|
||||||
(void) memcpy (name, file, len);
|
startp = name + 1;
|
||||||
else
|
else
|
||||||
{
|
startp = (char *) memcpy (name - (p - path), path, p - path);
|
||||||
/* Construct the pathname to try. */
|
|
||||||
char *tmp = __mempcpy (name, path, p - path);
|
|
||||||
*tmp++ = '/';
|
|
||||||
memcpy (tmp, file, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Try to execute this name. If it works, execv will not return. */
|
/* Try to execute this name. If it works, execv will not return. */
|
||||||
execv (name, argv);
|
__execve (startp, argv, __environ);
|
||||||
|
|
||||||
if (errno == ENOEXEC)
|
if (errno == ENOEXEC)
|
||||||
script_execute (name, argv);
|
script_execute (startp, argv);
|
||||||
|
|
||||||
switch (errno)
|
switch (errno)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user