diff options
author | Ulrich Drepper <drepper@redhat.com> | 2003-09-02 07:14:15 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2003-09-02 07:14:15 +0000 |
commit | f1c30c98b9c9720f2a542df7ae0b9cde4c162e7a (patch) | |
tree | 316c77f8647401e15d064910b7f33b0d2c84050d /sysdeps/generic | |
parent | c503d3dc512a5f7947d5b3d69d784028db3a639a (diff) | |
download | glibc-f1c30c98b9c9720f2a542df7ae0b9cde4c162e7a.tar.gz |
(CFLAGS-oldtmpfile.c): Add -fexceptions.
Diffstat (limited to 'sysdeps/generic')
-rw-r--r-- | sysdeps/generic/tmpfile.c | 4 | ||||
-rw-r--r-- | sysdeps/generic/wordexp.c | 39 |
2 files changed, 28 insertions, 15 deletions
diff --git a/sysdeps/generic/tmpfile.c b/sysdeps/generic/tmpfile.c index 847a7446b3..41f12bc8ba 100644 --- a/sysdeps/generic/tmpfile.c +++ b/sysdeps/generic/tmpfile.c @@ -1,5 +1,5 @@ /* Open a stdio stream on an anonymous temporary file. Generic/POSIX version. - Copyright (C) 1991,93,96,97,98,99,2000,2002 Free Software Foundation, Inc. + Copyright (C) 1991,93,1996-2000,2002,2003 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -51,7 +51,7 @@ tmpfile (void) /* Note that this relies on the Unix semantics that a file is not really removed until it is closed. */ - (void) remove (buf); + (void) __unlink (buf); if ((f = __fdopen (fd, "w+b")) == NULL) __close (fd); diff --git a/sysdeps/generic/wordexp.c b/sysdeps/generic/wordexp.c index bb870c967d..ae9fabb9b1 100644 --- a/sysdeps/generic/wordexp.c +++ b/sysdeps/generic/wordexp.c @@ -18,6 +18,7 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#include <alloca.h> #include <ctype.h> #include <errno.h> #include <fcntl.h> @@ -42,6 +43,7 @@ #endif #include <wordexp.h> +#include <bits/libc-lock.h> #include <stdio-common/_itoa.h> /* Undefine the following line for the production version. */ @@ -327,10 +329,7 @@ parse_tilde (char **word, size_t *word_length, size_t *max_length, while ((result = __getpwuid_r (uid, &pwd, buffer, buflen, &tpwd)) != 0 && errno == ERANGE) - { - buflen += 1000; - buffer = __alloca (buflen); - } + extend_alloca (buffer, buflen, buflen + 1000); if (result == 0 && tpwd != NULL && pwd.pw_dir != NULL) { @@ -357,10 +356,7 @@ parse_tilde (char **word, size_t *word_length, size_t *max_length, while ((result = __getpwnam_r (user, &pwd, buffer, buflen, &tpwd)) != 0 && errno == ERANGE) - { - buflen += 1000; - buffer = __alloca (buflen); - } + extend_alloca (buffer, buflen, buflen + 1000); if (result == 0 && tpwd != NULL && pwd.pw_dir) *word = w_addstr (*word, word_length, max_length, pwd.pw_dir); @@ -840,7 +836,7 @@ exec_comm_child (char *comm, int *fildes, int showerr, int noexec) args[1] = "-nc"; /* Redirect output. */ - __dup2 (fildes[1], 1); + __dup2 (fildes[1], STDOUT_FILENO); __close (fildes[1]); /* Redirect stderr to /dev/null if we have to. */ @@ -852,12 +848,12 @@ exec_comm_child (char *comm, int *fildes, int showerr, int noexec) fd = __open (_PATH_DEVNULL, O_WRONLY); if (fd >= 0 && fd != 2) { - __dup2 (fd, 2); + __dup2 (fd, STDERR_FILENO); __close (fd); } /* Be paranoid. Check that we actually opened the /dev/null device. */ - if (__builtin_expect (__fxstat64 (_STAT_VER, 2, &st), 0) != 0 + if (__builtin_expect (__fxstat64 (_STAT_VER, STDERR_FILENO, &st), 0) != 0 || __builtin_expect (S_ISCHR (st.st_mode), 1) == 0 #if defined DEV_NULL_MAJOR && defined DEV_NULL_MINOR || st.st_rdev != makedev (DEV_NULL_MAJOR, DEV_NULL_MINOR) @@ -913,7 +909,7 @@ exec_comm (char *comm, char **word, size_t *word_length, size_t *max_length, } if (pid == 0) - exec_comm_child(comm, fildes, (flags & WRDE_SHOWERR), 0); + exec_comm_child (comm, fildes, flags & WRDE_SHOWERR, 0); /* Parent */ @@ -1086,7 +1082,7 @@ exec_comm (char *comm, char **word, size_t *word_length, size_t *max_length, if (pid == 0) { fildes[0] = fildes[1] = -1; - exec_comm_child(comm, fildes, 0, 1); + exec_comm_child (comm, fildes, 0, 1); } if (__waitpid (pid, &status, 0) == pid && status != 0) @@ -1142,8 +1138,25 @@ parse_comm (char **word, size_t *word_length, size_t *max_length, /* Go -- give script to the shell */ if (comm) { +#ifdef __libc_ptf_call + /* We do not want the exec_comm call to be cut short + by a thread cancellation since cleanup is very + ugly. Therefore disable cancellation for + now. */ + // XXX Ideally we do want the thread being cancelable. + // XXX If demand is there we'll change it. + int state = PTHREAD_CANCEL_ENABLE; + __libc_ptf_call (pthread_setcancelstate, + (PTHREAD_CANCEL_DISABLE, &state), 0); +#endif + error = exec_comm (comm, word, word_length, max_length, flags, pwordexp, ifs, ifs_white); + +#ifdef __libc_ptf_call + __libc_ptf_call (pthread_setcancelstate, (state, NULL), 0); +#endif + free (comm); } |