mirror of
https://sourceware.org/git/glibc.git
synced 2025-01-03 16:21:06 +00:00
* posix/execvp.c: Include alloca.h.
(allocate_scripts_argv): Renamed to... (scripts_argv): ... this. Don't allocate buffer here nor count arguments. (execvp): Use alloca if possible. * posix/Makefile: Add rules to build and run tst-vfork3 test. * posix/tst-vfork3.c: New test. 2007-01-03 Ulrich Drepper <drepper@redhat.com> * string/Makefile (tst-strxfrm2-ENV): Define. * stdlib/Makefile (tst-strtod3-ENV): Define.
This commit is contained in:
parent
64a0aa0fac
commit
df859a0c15
15
ChangeLog
15
ChangeLog
@ -1,3 +1,18 @@
|
|||||||
|
2007-01-03 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
|
* posix/execvp.c: Include alloca.h.
|
||||||
|
(allocate_scripts_argv): Renamed to...
|
||||||
|
(scripts_argv): ... this. Don't allocate buffer here nor count
|
||||||
|
arguments.
|
||||||
|
(execvp): Use alloca if possible.
|
||||||
|
* posix/Makefile: Add rules to build and run tst-vfork3 test.
|
||||||
|
* posix/tst-vfork3.c: New test.
|
||||||
|
|
||||||
|
2007-01-03 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* string/Makefile (tst-strxfrm2-ENV): Define.
|
||||||
|
* stdlib/Makefile (tst-strtod3-ENV): Define.
|
||||||
|
|
||||||
2007-01-02 Ulrich Drepper <drepper@redhat.com>
|
2007-01-02 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
* posix/getconf.c: Update copyright year.
|
* posix/getconf.c: Update copyright year.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (C) 1991-1999, 2000-2005, 2006 Free Software Foundation, Inc.
|
# Copyright (C) 1991-1999, 2000-2006, 2007 Free Software Foundation, Inc.
|
||||||
# This file is part of the GNU C Library.
|
# This file is part of the GNU C Library.
|
||||||
|
|
||||||
# The GNU C Library is free software; you can redistribute it and/or
|
# The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -83,7 +83,7 @@ tests := tstgetopt testfnm runtests runptests \
|
|||||||
bug-regex21 bug-regex22 bug-regex23 bug-regex24 \
|
bug-regex21 bug-regex22 bug-regex23 bug-regex24 \
|
||||||
bug-regex25 bug-regex26 tst-nice tst-nanosleep tst-regex2 \
|
bug-regex25 bug-regex26 tst-nice tst-nanosleep tst-regex2 \
|
||||||
transbug tst-rxspencer tst-pcre tst-boost \
|
transbug tst-rxspencer tst-pcre tst-boost \
|
||||||
bug-ga1 tst-vfork1 tst-vfork2 tst-waitid \
|
bug-ga1 tst-vfork1 tst-vfork2 tst-vfork3 tst-waitid \
|
||||||
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 \
|
||||||
@ -108,7 +108,8 @@ generated := $(addprefix wordexp-test-result, 1 2 3 4 5 6 7 8 9 10) \
|
|||||||
bug-regex21-mem bug-regex21.mtrace \
|
bug-regex21-mem bug-regex21.mtrace \
|
||||||
tst-rxspencer-mem tst-rxspencer.mtrace tst-getconf.out \
|
tst-rxspencer-mem tst-rxspencer.mtrace tst-getconf.out \
|
||||||
tst-pcre-mem tst-pcre.mtrace tst-boost-mem tst-boost.mtrace \
|
tst-pcre-mem tst-pcre.mtrace tst-boost-mem tst-boost.mtrace \
|
||||||
bug-ga2.mtrace bug-ga2-mem bug-glob2.mtrace bug-glob2-mem
|
bug-ga2.mtrace bug-ga2-mem bug-glob2.mtrace bug-glob2-mem \
|
||||||
|
tst-vfork3-mem tst-vfork3.mtrace
|
||||||
|
|
||||||
include ../Rules
|
include ../Rules
|
||||||
|
|
||||||
@ -174,6 +175,7 @@ tst-exec-ARGS = -- $(built-program-cmd)
|
|||||||
tst-spawn-ARGS = -- $(built-program-cmd)
|
tst-spawn-ARGS = -- $(built-program-cmd)
|
||||||
tst-dir-ARGS = `pwd` `cd $(common-objdir)/$(subdir); pwd` `cd $(common-objdir); pwd` $(objpfx)tst-dir
|
tst-dir-ARGS = `pwd` `cd $(common-objdir)/$(subdir); pwd` `cd $(common-objdir); pwd` $(objpfx)tst-dir
|
||||||
tst-chmod-ARGS = `pwd`
|
tst-chmod-ARGS = `pwd`
|
||||||
|
tst-vfork3-ARGS = --test-dir=$(objpfx)
|
||||||
|
|
||||||
tst-fnmatch-ENV = LOCPATH=$(common-objpfx)localedata
|
tst-fnmatch-ENV = LOCPATH=$(common-objpfx)localedata
|
||||||
tst-regexloc-ENV = LOCPATH=$(common-objpfx)localedata
|
tst-regexloc-ENV = LOCPATH=$(common-objpfx)localedata
|
||||||
@ -218,7 +220,7 @@ ifeq (no,$(cross-compiling))
|
|||||||
tests: $(objpfx)bug-regex2-mem $(objpfx)bug-regex14-mem \
|
tests: $(objpfx)bug-regex2-mem $(objpfx)bug-regex14-mem \
|
||||||
$(objpfx)bug-regex21-mem $(objpfx)tst-rxspencer-mem \
|
$(objpfx)bug-regex21-mem $(objpfx)tst-rxspencer-mem \
|
||||||
$(objpfx)tst-pcre-mem $(objpfx)tst-boost-mem $(objpfx)tst-getconf.out \
|
$(objpfx)tst-pcre-mem $(objpfx)tst-boost-mem $(objpfx)tst-getconf.out \
|
||||||
$(objpfx)bug-glob2-mem
|
$(objpfx)bug-glob2-mem $(objpfx)tst-vfork3-mem
|
||||||
xtests: $(objpfx)bug-ga2-mem
|
xtests: $(objpfx)bug-ga2-mem
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -245,6 +247,11 @@ bug-regex21-ENV = MALLOC_TRACE=$(objpfx)bug-regex21.mtrace
|
|||||||
$(objpfx)bug-regex21-mem: $(objpfx)bug-regex21.out
|
$(objpfx)bug-regex21-mem: $(objpfx)bug-regex21.out
|
||||||
$(common-objpfx)malloc/mtrace $(objpfx)bug-regex21.mtrace > $@
|
$(common-objpfx)malloc/mtrace $(objpfx)bug-regex21.mtrace > $@
|
||||||
|
|
||||||
|
tst-vfork3-ENV = MALLOC_TRACE=$(objpfx)tst-vfork3.mtrace
|
||||||
|
|
||||||
|
$(objpfx)tst-vfork3-mem: $(objpfx)tst-vfork3.out
|
||||||
|
$(common-objpfx)malloc/mtrace $(objpfx)tst-vfork3.mtrace > $@
|
||||||
|
|
||||||
# tst-rxspencer.mtrace is generated only when run without --utf8
|
# tst-rxspencer.mtrace is generated only when run without --utf8
|
||||||
# option, since otherwise the file has almost 100M and takes very long
|
# option, since otherwise the file has almost 100M and takes very long
|
||||||
# time to process.
|
# time to process.
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
/* Copyright (C) 1991,92,1995-99,2002,2004,2005 Free Software Foundation, Inc.
|
/* Copyright (C) 1991,92, 1995-99, 2002, 2004, 2005, 2007
|
||||||
|
Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -16,6 +17,7 @@
|
|||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
02111-1307 USA. */
|
02111-1307 USA. */
|
||||||
|
|
||||||
|
#include <alloca.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
@ -27,19 +29,11 @@
|
|||||||
|
|
||||||
/* The file is accessible but it is not an executable file. Invoke
|
/* The file is accessible but it is not an executable file. Invoke
|
||||||
the shell to interpret it as a script. */
|
the shell to interpret it as a script. */
|
||||||
static char **
|
static void
|
||||||
internal_function
|
internal_function
|
||||||
allocate_scripts_argv (const char *file, char *const argv[])
|
scripts_argv (const char *file, char *const argv[], int argc, char **new_argv)
|
||||||
{
|
{
|
||||||
/* Count the arguments. */
|
|
||||||
int argc = 0;
|
|
||||||
while (argv[argc++])
|
|
||||||
;
|
|
||||||
|
|
||||||
/* Construct an argument list for the shell. */
|
/* Construct an argument list for the shell. */
|
||||||
char **new_argv = (char **) malloc ((argc + 1) * sizeof (char *));
|
|
||||||
if (new_argv != NULL)
|
|
||||||
{
|
|
||||||
new_argv[0] = (char *) _PATH_BSHELL;
|
new_argv[0] = (char *) _PATH_BSHELL;
|
||||||
new_argv[1] = (char *) file;
|
new_argv[1] = (char *) file;
|
||||||
while (argc > 1)
|
while (argc > 1)
|
||||||
@ -49,9 +43,6 @@ allocate_scripts_argv (const char *file, char *const argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new_argv;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Execute FILE, searching in the `PATH' environment variable if it contains
|
/* Execute FILE, searching in the `PATH' environment variable if it contains
|
||||||
no slashes, with arguments ARGV and environment from `environ'. */
|
no slashes, with arguments ARGV and environment from `environ'. */
|
||||||
@ -67,8 +58,6 @@ execvp (file, argv)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
char **script_argv = NULL;
|
|
||||||
|
|
||||||
if (strchr (file, '/') != NULL)
|
if (strchr (file, '/') != NULL)
|
||||||
{
|
{
|
||||||
/* Don't search when it contains a slash. */
|
/* Don't search when it contains a slash. */
|
||||||
@ -76,46 +65,71 @@ execvp (file, argv)
|
|||||||
|
|
||||||
if (errno == ENOEXEC)
|
if (errno == ENOEXEC)
|
||||||
{
|
{
|
||||||
script_argv = allocate_scripts_argv (file, argv);
|
/* Count the arguments. */
|
||||||
|
int argc = 0;
|
||||||
|
while (argv[argc++])
|
||||||
|
;
|
||||||
|
size_t len = (argc + 1) * sizeof (char *);
|
||||||
|
char **script_argv;
|
||||||
|
void *ptr = NULL;
|
||||||
|
if (__libc_use_alloca (len))
|
||||||
|
script_argv = alloca (len);
|
||||||
|
else
|
||||||
|
script_argv = ptr = malloc (len);
|
||||||
|
|
||||||
if (script_argv != NULL)
|
if (script_argv != NULL)
|
||||||
{
|
{
|
||||||
|
scripts_argv (file, argv, argc, script_argv);
|
||||||
__execve (script_argv[0], script_argv, __environ);
|
__execve (script_argv[0], script_argv, __environ);
|
||||||
|
|
||||||
free (script_argv);
|
free (ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
size_t pathlen;
|
||||||
|
size_t alloclen = 0;
|
||||||
char *path = getenv ("PATH");
|
char *path = getenv ("PATH");
|
||||||
|
if (path == NULL)
|
||||||
|
{
|
||||||
|
pathlen = confstr (_CS_PATH, (char *) NULL, 0);
|
||||||
|
alloclen = pathlen + 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
pathlen = strlen (path);
|
||||||
|
|
||||||
|
size_t len = strlen (file) + 1;
|
||||||
|
alloclen += pathlen + len + 1;
|
||||||
|
|
||||||
|
char *name;
|
||||||
char *path_malloc = NULL;
|
char *path_malloc = NULL;
|
||||||
|
if (__libc_use_alloca (alloclen))
|
||||||
|
name = alloca (alloclen);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
path_malloc = name = malloc (alloclen);
|
||||||
|
if (name == NULL)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (path == NULL)
|
if (path == NULL)
|
||||||
{
|
{
|
||||||
/* There is no `PATH' in the environment.
|
/* There is no `PATH' in the environment.
|
||||||
The default search path is the current directory
|
The default search path is the current directory
|
||||||
followed by the path `confstr' returns for `_CS_PATH'. */
|
followed by the path `confstr' returns for `_CS_PATH'. */
|
||||||
size_t len = confstr (_CS_PATH, (char *) NULL, 0);
|
path = name + pathlen + len + 1;
|
||||||
path = (char *) malloc (1 + len);
|
|
||||||
if (path == NULL)
|
|
||||||
return -1;
|
|
||||||
path[0] = ':';
|
path[0] = ':';
|
||||||
(void) confstr (_CS_PATH, path + 1, len);
|
(void) confstr (_CS_PATH, path + 1, pathlen);
|
||||||
path_malloc = path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t len = strlen (file) + 1;
|
|
||||||
size_t pathlen = strlen (path);
|
|
||||||
char *name = malloc (pathlen + len + 1);
|
|
||||||
if (name == NULL)
|
|
||||||
{
|
|
||||||
free (path_malloc);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
/* Copy the file name at the top. */
|
/* Copy the file name at the top. */
|
||||||
name = (char *) memcpy (name + pathlen + 1, file, len);
|
name = (char *) memcpy (name + pathlen + 1, file, len);
|
||||||
/* And add the slash. */
|
/* And add the slash. */
|
||||||
*--name = '/';
|
*--name = '/';
|
||||||
|
|
||||||
|
char **script_argv = NULL;
|
||||||
|
void *script_argv_malloc = NULL;
|
||||||
bool got_eacces = false;
|
bool got_eacces = false;
|
||||||
char *p = path;
|
char *p = path;
|
||||||
do
|
do
|
||||||
@ -139,7 +153,15 @@ execvp (file, argv)
|
|||||||
{
|
{
|
||||||
if (script_argv == NULL)
|
if (script_argv == NULL)
|
||||||
{
|
{
|
||||||
script_argv = allocate_scripts_argv (startp, argv);
|
/* Count the arguments. */
|
||||||
|
int argc = 0;
|
||||||
|
while (argv[argc++])
|
||||||
|
;
|
||||||
|
size_t arglen = (argc + 1) * sizeof (char *);
|
||||||
|
if (__libc_use_alloca (alloclen + arglen))
|
||||||
|
script_argv = alloca (arglen);
|
||||||
|
else
|
||||||
|
script_argv = script_argv_malloc = malloc (arglen);
|
||||||
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
|
||||||
@ -147,6 +169,7 @@ execvp (file, argv)
|
|||||||
got_eacces = false;
|
got_eacces = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
scripts_argv (startp, argv, argc, script_argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
__execve (script_argv[0], script_argv, __environ);
|
__execve (script_argv[0], script_argv, __environ);
|
||||||
@ -187,8 +210,7 @@ execvp (file, argv)
|
|||||||
error. */
|
error. */
|
||||||
__set_errno (EACCES);
|
__set_errno (EACCES);
|
||||||
|
|
||||||
free (script_argv);
|
free (script_argv_malloc);
|
||||||
free (name - pathlen);
|
|
||||||
free (path_malloc);
|
free (path_malloc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
224
posix/tst-vfork3.c
Normal file
224
posix/tst-vfork3.c
Normal file
@ -0,0 +1,224 @@
|
|||||||
|
/* Test for vfork functions.
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
Contributed by Jakub Jelinek <jakub@redhat.com>, 2007.
|
||||||
|
|
||||||
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
The GNU C Library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with the GNU C Library; if not, write to the Free
|
||||||
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
|
02111-1307 USA. */
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <mcheck.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
static int do_test (void);
|
||||||
|
static void do_prepare (void);
|
||||||
|
char *tmpdirname;
|
||||||
|
|
||||||
|
#define TEST_FUNCTION do_test ()
|
||||||
|
#define PREPARE(argc, argv) do_prepare ()
|
||||||
|
#include "../test-skeleton.c"
|
||||||
|
|
||||||
|
static int
|
||||||
|
do_test (void)
|
||||||
|
{
|
||||||
|
mtrace ();
|
||||||
|
|
||||||
|
const char *path = getenv ("PATH");
|
||||||
|
if (path == NULL)
|
||||||
|
path = "/bin";
|
||||||
|
char pathbuf[strlen (tmpdirname) + 1 + strlen (path) + 1];
|
||||||
|
strcpy (stpcpy (stpcpy (pathbuf, tmpdirname), ":"), path);
|
||||||
|
if (setenv ("PATH", pathbuf, 1) < 0)
|
||||||
|
{
|
||||||
|
puts ("setenv failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t i;
|
||||||
|
char *argv[3] = { (char *) "script1.sh", (char *) "1", NULL };
|
||||||
|
for (i = 0; i < 5; i++)
|
||||||
|
{
|
||||||
|
pid_t pid = vfork ();
|
||||||
|
if (pid < 0)
|
||||||
|
{
|
||||||
|
printf ("vfork failed: %m\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if (pid == 0)
|
||||||
|
{
|
||||||
|
execvp ("script1.sh", argv);
|
||||||
|
_exit (errno);
|
||||||
|
}
|
||||||
|
int status;
|
||||||
|
if (TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)) != pid)
|
||||||
|
{
|
||||||
|
puts ("waitpid failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if (status != 0)
|
||||||
|
{
|
||||||
|
if (WIFEXITED (status))
|
||||||
|
printf ("script1.sh failed with status %d\n",
|
||||||
|
WEXITSTATUS (status));
|
||||||
|
else
|
||||||
|
printf ("script1.sh kill by signal %d\n",
|
||||||
|
WTERMSIG (status));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
argv[0] = (char *) "script2.sh";
|
||||||
|
argv[1] = (char *) "2";
|
||||||
|
for (i = 0; i < 5; i++)
|
||||||
|
{
|
||||||
|
pid_t pid = vfork ();
|
||||||
|
if (pid < 0)
|
||||||
|
{
|
||||||
|
printf ("vfork failed: %m\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if (pid == 0)
|
||||||
|
{
|
||||||
|
execvp ("script2.sh", argv);
|
||||||
|
_exit (errno);
|
||||||
|
}
|
||||||
|
int status;
|
||||||
|
if (TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)) != pid)
|
||||||
|
{
|
||||||
|
puts ("waitpid failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if (status != 0)
|
||||||
|
{
|
||||||
|
printf ("script2.sh failed with status %d\n", status);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < 5; i++)
|
||||||
|
{
|
||||||
|
pid_t pid = vfork ();
|
||||||
|
if (pid < 0)
|
||||||
|
{
|
||||||
|
printf ("vfork failed: %m\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if (pid == 0)
|
||||||
|
{
|
||||||
|
execlp ("script2.sh", "script2.sh", "3", NULL);
|
||||||
|
_exit (errno);
|
||||||
|
}
|
||||||
|
int status;
|
||||||
|
if (TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)) != pid)
|
||||||
|
{
|
||||||
|
puts ("waitpid failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if (status != 0)
|
||||||
|
{
|
||||||
|
printf ("script2.sh failed with status %d\n", status);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsetenv ("PATH");
|
||||||
|
argv[0] = (char *) "echo";
|
||||||
|
argv[1] = (char *) "script 4";
|
||||||
|
for (i = 0; i < 5; i++)
|
||||||
|
{
|
||||||
|
pid_t pid = vfork ();
|
||||||
|
if (pid < 0)
|
||||||
|
{
|
||||||
|
printf ("vfork failed: %m\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if (pid == 0)
|
||||||
|
{
|
||||||
|
execvp ("echo", argv);
|
||||||
|
_exit (errno);
|
||||||
|
}
|
||||||
|
int status;
|
||||||
|
if (TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)) != pid)
|
||||||
|
{
|
||||||
|
puts ("waitpid failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if (status != 0)
|
||||||
|
{
|
||||||
|
printf ("echo failed with status %d\n", status);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
do_prepare (void)
|
||||||
|
{
|
||||||
|
size_t len = strlen (test_dir) + sizeof ("/tst-vfork3.XXXXXX");
|
||||||
|
tmpdirname = malloc (len);
|
||||||
|
char *script1 = malloc (len + sizeof "/script1.sh");
|
||||||
|
char *script2 = malloc (len + sizeof "/script2.sh");
|
||||||
|
if (tmpdirname == NULL || script1 == NULL || script2 == NULL)
|
||||||
|
{
|
||||||
|
puts ("out of memory");
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
strcpy (stpcpy (tmpdirname, test_dir), "/tst-vfork3.XXXXXX");
|
||||||
|
|
||||||
|
tmpdirname = mkdtemp (tmpdirname);
|
||||||
|
if (tmpdirname == NULL)
|
||||||
|
{
|
||||||
|
puts ("could not create temporary directory");
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
strcpy (stpcpy (script1, tmpdirname), "/script1.sh");
|
||||||
|
strcpy (stpcpy (script2, tmpdirname), "/script2.sh");
|
||||||
|
|
||||||
|
/* Need to make sure tmpdirname is at the end of the linked list. */
|
||||||
|
add_temp_file (script1);
|
||||||
|
add_temp_file (tmpdirname);
|
||||||
|
add_temp_file (script2);
|
||||||
|
|
||||||
|
const char content1[] = "#!/bin/sh\necho script $1\n";
|
||||||
|
int fd = open (script1, O_WRONLY | O_CREAT, 0700);
|
||||||
|
if (fd < 0
|
||||||
|
|| TEMP_FAILURE_RETRY (write (fd, content1, sizeof content1))
|
||||||
|
!= sizeof content1
|
||||||
|
|| fchmod (fd, S_IRUSR | S_IXUSR) < 0)
|
||||||
|
{
|
||||||
|
printf ("Could not write %s\n", script1);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
close (fd);
|
||||||
|
|
||||||
|
const char content2[] = "echo script $1\n";
|
||||||
|
fd = open (script2, O_WRONLY | O_CREAT, 0700);
|
||||||
|
if (fd < 0
|
||||||
|
|| TEMP_FAILURE_RETRY (write (fd, content2, sizeof content2))
|
||||||
|
!= sizeof content2
|
||||||
|
|| fchmod (fd, S_IRUSR | S_IXUSR) < 0)
|
||||||
|
{
|
||||||
|
printf ("Could not write %s\n", script2);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
close (fd);
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (C) 1991-2002,2003,2004,2005,2006 Free Software Foundation, Inc.
|
# Copyright (C) 1991-2006, 2007 Free Software Foundation, Inc.
|
||||||
# This file is part of the GNU C Library.
|
# This file is part of the GNU C Library.
|
||||||
|
|
||||||
# The GNU C Library is free software; you can redistribute it and/or
|
# The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -113,6 +113,7 @@ include ../Rules
|
|||||||
test-canon-ARGS = --test-dir=${common-objpfx}stdlib
|
test-canon-ARGS = --test-dir=${common-objpfx}stdlib
|
||||||
|
|
||||||
tst-strtod-ENV = LOCPATH=$(common-objpfx)localedata
|
tst-strtod-ENV = LOCPATH=$(common-objpfx)localedata
|
||||||
|
tst-strtod3-ENV = LOCPATH=$(common-objpfx)localedata
|
||||||
testmb2-ENV = LOCPATH=$(common-objpfx)localedata
|
testmb2-ENV = LOCPATH=$(common-objpfx)localedata
|
||||||
|
|
||||||
# Run a test on the header files we use.
|
# Run a test on the header files we use.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (C) 1991-2002, 2005, 2006 Free Software Foundation, Inc.
|
# Copyright (C) 1991-2002, 2005, 2006, 2007 Free Software Foundation, Inc.
|
||||||
# This file is part of the GNU C Library.
|
# This file is part of the GNU C Library.
|
||||||
|
|
||||||
# The GNU C Library is free software; you can redistribute it and/or
|
# The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -64,6 +64,7 @@ tester-ENV = LANGUAGE=C
|
|||||||
inl-tester-ENV = LANGUAGE=C
|
inl-tester-ENV = LANGUAGE=C
|
||||||
noinl-tester-ENV = LANGUAGE=C
|
noinl-tester-ENV = LANGUAGE=C
|
||||||
tst-strxfrm-ENV = LOCPATH=$(common-objpfx)localedata
|
tst-strxfrm-ENV = LOCPATH=$(common-objpfx)localedata
|
||||||
|
tst-strxfrm2-ENV = LOCPATH=$(common-objpfx)localedata
|
||||||
bug-strcoll1-ENV = LOCPATH=$(common-objpfx)localedata
|
bug-strcoll1-ENV = LOCPATH=$(common-objpfx)localedata
|
||||||
CFLAGS-inl-tester.c = -fno-builtin
|
CFLAGS-inl-tester.c = -fno-builtin
|
||||||
CFLAGS-noinl-tester.c = -fno-builtin
|
CFLAGS-noinl-tester.c = -fno-builtin
|
||||||
|
Loading…
Reference in New Issue
Block a user