summaryrefslogtreecommitdiff
path: root/sysdeps/generic
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2005-02-16 19:57:14 +0000
committerRoland McGrath <roland@gnu.org>2005-02-16 19:57:14 +0000
commit7cd274587760436effbfce65cfdbd51f761acd67 (patch)
tree8620654b8197c81aded8a206680e53b4294baccf /sysdeps/generic
parentaa29d418cf3ee21f906247b6ab49e8aab6fd19dc (diff)
Updated to fedora-glibc-2_3-20050216T1256
Diffstat (limited to 'sysdeps/generic')
-rw-r--r--sysdeps/generic/dl-tls.c11
-rw-r--r--sysdeps/generic/libc-start.c2
-rw-r--r--sysdeps/generic/wordexp.c58
3 files changed, 38 insertions, 33 deletions
diff --git a/sysdeps/generic/dl-tls.c b/sysdeps/generic/dl-tls.c
index 3382e3493c..03a45c7c88 100644
--- a/sysdeps/generic/dl-tls.c
+++ b/sysdeps/generic/dl-tls.c
@@ -65,7 +65,10 @@ _dl_next_tls_modid (void)
/* Note that this branch will never be executed during program
start since there are no gaps at that time. Therefore it
does not matter that the dl_tls_dtv_slotinfo is not allocated
- yet when the function is called for the first times. */
+ yet when the function is called for the first times.
+
+ NB: the offset +1 is due to the fact that DTV[0] is used
+ for something else. */
result = GL(dl_tls_static_nelem) + 1;
/* If the following would not be true we mustn't have assumed
there is a gap. */
@@ -88,11 +91,11 @@ _dl_next_tls_modid (void)
}
while ((runp = runp->next) != NULL);
- if (result >= GL(dl_tls_max_dtv_idx))
+ if (result > GL(dl_tls_max_dtv_idx))
{
/* The new index must indeed be exactly one higher than the
previous high. */
- assert (result == GL(dl_tls_max_dtv_idx));
+ assert (result == GL(dl_tls_max_dtv_idx) + 1);
/* There is no gap anymore. */
GL(dl_tls_dtv_gaps) = false;
@@ -577,7 +580,7 @@ __tls_get_addr (GET_ADDR_ARGS)
{
size_t cnt;
- for (cnt = total = 0 ? 1 : 0; cnt < listp->len; ++cnt)
+ for (cnt = total == 0 ? 1 : 0; cnt < listp->len; ++cnt)
{
size_t gen = listp->slotinfo[cnt].gen;
struct link_map *map;
diff --git a/sysdeps/generic/libc-start.c b/sysdeps/generic/libc-start.c
index fc9df40996..0a8b0ce32a 100644
--- a/sysdeps/generic/libc-start.c
+++ b/sysdeps/generic/libc-start.c
@@ -106,9 +106,9 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
__libc_multiple_libcs = &_dl_starting_up && !_dl_starting_up;
+#ifndef SHARED
INIT_ARGV_and_ENVIRON;
-#ifndef SHARED
/* Store the lowest stack address. This is done in ld.so if this is
the code for the DSO. */
__libc_stack_end = stack_end;
diff --git a/sysdeps/generic/wordexp.c b/sysdeps/generic/wordexp.c
index 3e37d6449c..852e171767 100644
--- a/sysdeps/generic/wordexp.c
+++ b/sysdeps/generic/wordexp.c
@@ -810,7 +810,7 @@ parse_arith (char **word, size_t *word_length, size_t *max_length,
/* Function called by child process in exec_comm() */
static void
-internal_function
+internal_function __attribute__ ((always_inline))
exec_comm_child (char *comm, int *fildes, int showerr, int noexec)
{
const char *args[4] = { _PATH_BSHELL, "-c", comm, NULL };
@@ -868,13 +868,14 @@ exec_comm (char *comm, char **word, size_t *word_length, size_t *max_length,
const char *ifs_white)
{
int fildes[2];
- int bufsize = 128;
+#define bufsize 128
int buflen;
int i;
int status = 0;
size_t maxnewlines = 0;
- char *buffer;
+ char buffer[bufsize];
pid_t pid;
+ int noexec = 0;
/* Don't fork() unless necessary */
if (!comm || !*comm)
@@ -884,32 +885,42 @@ exec_comm (char *comm, char **word, size_t *word_length, size_t *max_length,
/* Bad */
return WRDE_NOSPACE;
+ again:
if ((pid = __fork ()) < 0)
{
/* Bad */
- __close (fildes[0]);
- __close (fildes[1]);
+ if (fildes[0] != -1)
+ __close (fildes[0]);
+ if (fildes[1] != -1)
+ __close (fildes[1]);
return WRDE_NOSPACE;
}
if (pid == 0)
- exec_comm_child (comm, fildes, flags & WRDE_SHOWERR, 0);
+ exec_comm_child (comm, fildes, noexec ? 0 : flags & WRDE_SHOWERR, noexec);
/* Parent */
+ /* If we are just testing the syntax, only wait. */
+ if (noexec)
+ return (TEMP_FAILURE_RETRY (__waitpid (pid, &status, 0)) == pid
+ && status != 0) ? WRDE_SYNTAX : 0;
+
__close (fildes[1]);
- buffer = __alloca (bufsize);
+ fildes[1] = -1;
if (!pwordexp)
/* Quoted - no field splitting */
{
while (1)
{
- if ((buflen = __read (fildes[0], buffer, bufsize)) < 1)
+ if ((buflen = TEMP_FAILURE_RETRY (__read (fildes[0], buffer,
+ bufsize))) < 1)
{
- if (__waitpid (pid, &status, WNOHANG) == 0)
+ if (TEMP_FAILURE_RETRY (__waitpid (pid, &status, WNOHANG)) == 0)
continue;
- if ((buflen = __read (fildes[0], buffer, bufsize)) < 1)
+ if ((buflen = TEMP_FAILURE_RETRY (__read (fildes[0], buffer,
+ bufsize))) < 1)
break;
}
@@ -933,11 +944,13 @@ exec_comm (char *comm, char **word, size_t *word_length, size_t *max_length,
while (1)
{
- if ((buflen = __read (fildes[0], buffer, bufsize)) < 1)
+ if ((buflen = TEMP_FAILURE_RETRY (__read (fildes[0], buffer,
+ bufsize))) < 1)
{
- if (__waitpid (pid, &status, WNOHANG) == 0)
+ if (TEMP_FAILURE_RETRY (__waitpid (pid, &status, WNOHANG)) == 0)
continue;
- if ((buflen = __read (fildes[0], buffer, bufsize)) < 1)
+ if ((buflen = TEMP_FAILURE_RETRY (__read (fildes[0], buffer,
+ bufsize))) < 1)
break;
}
@@ -1053,31 +1066,20 @@ exec_comm (char *comm, char **word, size_t *word_length, size_t *max_length,
}
__close (fildes[0]);
+ fildes[0] = -1;
/* Check for syntax error (re-execute but with "-n" flag) */
if (buflen < 1 && status != 0)
{
- if ((pid = __fork ()) < 0)
- {
- /* Bad */
- return WRDE_NOSPACE;
- }
-
- if (pid == 0)
- {
- fildes[0] = fildes[1] = -1;
- exec_comm_child (comm, fildes, 0, 1);
- }
-
- if (__waitpid (pid, &status, 0) == pid && status != 0)
- return WRDE_SYNTAX;
+ noexec = 1;
+ goto again;
}
return 0;
no_space:
__kill (pid, SIGKILL);
- __waitpid (pid, NULL, 0);
+ TEMP_FAILURE_RETRY (__waitpid (pid, NULL, 0));
__close (fildes[0]);
return WRDE_NOSPACE;
}