mirror of
git://sourceware.org/git/glibc.git
synced 2024-11-21 01:12:26 +08:00
* posix/execvp.c (execvp): Use file name including path when
trying to run it with shell. * posix/Makefile: Add rules to build and run tst-execvp3. * posix/tst-execvp3.c: New file.
This commit is contained in:
parent
806bc96abb
commit
506cbf1f43
@ -1,3 +1,10 @@
|
|||||||
|
2005-04-14 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* posix/execvp.c (execvp): Use file name including path when
|
||||||
|
trying to run it with shell.
|
||||||
|
* posix/Makefile: Add rules to build and run tst-execvp3.
|
||||||
|
* posix/tst-execvp3.c: New file.
|
||||||
|
|
||||||
2005-04-12 Ulrich Drepper <drepper@redhat.com>
|
2005-04-12 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
* stdlib/random_r.c (__initstate_r): Don't use non-existing state.
|
* stdlib/random_r.c (__initstate_r): Don't use non-existing state.
|
||||||
|
@ -86,7 +86,8 @@ tests := tstgetopt testfnm runtests runptests \
|
|||||||
tst-getaddrinfo2 bug-glob1 bug-glob2 tst-sysconf \
|
tst-getaddrinfo2 bug-glob1 bug-glob2 tst-sysconf \
|
||||||
tst-execvp1 tst-execvp2 tst-execlp1 tst-execlp2 \
|
tst-execvp1 tst-execvp2 tst-execlp1 tst-execlp2 \
|
||||||
tst-execv1 tst-execv2 tst-execl1 tst-execl2 \
|
tst-execv1 tst-execv2 tst-execl1 tst-execl2 \
|
||||||
tst-execve1 tst-execve2 tst-execle1 tst-execle2
|
tst-execve1 tst-execve2 tst-execle1 tst-execle2 \
|
||||||
|
tst-execvp3
|
||||||
xtests := bug-ga2
|
xtests := bug-ga2
|
||||||
ifeq (yes,$(build-shared))
|
ifeq (yes,$(build-shared))
|
||||||
test-srcs := globtest
|
test-srcs := globtest
|
||||||
@ -190,6 +191,7 @@ tst-rxspencer-ENV = LOCPATH=$(common-objpfx)localedata
|
|||||||
tst-pcre-ARGS = PCRE.tests
|
tst-pcre-ARGS = PCRE.tests
|
||||||
tst-boost-ARGS = BOOST.tests
|
tst-boost-ARGS = BOOST.tests
|
||||||
bug-glob1-ARGS = "$(objpfx)"
|
bug-glob1-ARGS = "$(objpfx)"
|
||||||
|
tst-execvp3-ARGS = --test-dir=$(objpfx)
|
||||||
|
|
||||||
testcases.h: TESTS TESTS2C.sed
|
testcases.h: TESTS TESTS2C.sed
|
||||||
sed -f TESTS2C.sed < $< > $@T
|
sed -f TESTS2C.sed < $< > $@T
|
||||||
|
@ -133,14 +133,14 @@ execvp (file, argv)
|
|||||||
else
|
else
|
||||||
startp = (char *) memcpy (name - (p - path), path, p - path);
|
startp = (char *) memcpy (name - (p - path), path, p - path);
|
||||||
|
|
||||||
/* Try to execute this name. If it works, execv will not return. */
|
/* Try to execute this name. If it works, execve will not return. */
|
||||||
__execve (startp, argv, __environ);
|
__execve (startp, argv, __environ);
|
||||||
|
|
||||||
if (errno == ENOEXEC)
|
if (errno == ENOEXEC)
|
||||||
{
|
{
|
||||||
if (script_argv == NULL)
|
if (script_argv == NULL)
|
||||||
{
|
{
|
||||||
script_argv = allocate_scripts_argv (file, argv);
|
script_argv = allocate_scripts_argv (startp, argv);
|
||||||
if (script_argv == NULL)
|
if (script_argv == NULL)
|
||||||
{
|
{
|
||||||
/* A possible EACCES error is not as important as
|
/* A possible EACCES error is not as important as
|
||||||
|
42
posix/tst-execvp3.c
Normal file
42
posix/tst-execvp3.c
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
|
||||||
|
static void do_prepare (void);
|
||||||
|
#define PREPARE(argc, argv) do_prepare ()
|
||||||
|
static int do_test (void);
|
||||||
|
#define TEST_FUNCTION do_test ()
|
||||||
|
|
||||||
|
#include "../test-skeleton.c"
|
||||||
|
|
||||||
|
|
||||||
|
static char *fname;
|
||||||
|
|
||||||
|
static void
|
||||||
|
do_prepare (void)
|
||||||
|
{
|
||||||
|
int fd = create_temp_file ("testscript", &fname);
|
||||||
|
dprintf (fd, "echo foo\n");
|
||||||
|
fchmod (fd, 0700);
|
||||||
|
close (fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
do_test (void)
|
||||||
|
{
|
||||||
|
if (setenv ("PATH", test_dir, 1) != 0)
|
||||||
|
{
|
||||||
|
puts ("setenv failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *argv[] = { fname, NULL };
|
||||||
|
execvp (basename (fname), argv);
|
||||||
|
|
||||||
|
/* If we come here, the execvp call failed. */
|
||||||
|
return 1;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user