From 06ff82f01ec2b6f88e50519a5ecc01b602d931c2 Mon Sep 17 00:00:00 2001 From: DJ Delorie Date: Thu, 31 Jul 2008 19:06:35 +0000 Subject: [PATCH] merge from gcc --- libiberty/ChangeLog | 8 ++++++++ libiberty/functions.texi | 16 +++++++++------- libiberty/make-temp-file.c | 12 ++++++++---- libiberty/mkstemps.c | 3 +++ 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index bf52f9eb4..da52583c8 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,11 @@ +2008-07-31 Denys Vlasenko + + * mkstemps.c (mkstemps): If open failed with errno other than + EEXIST, return immediately. + * make-temp-file.c: Include errno.h. + (make_temp_file): If mkstemps failed, print an error message + before aborting. + 2008-07-24 Ralf Wildenhues * maint-tool (deps): Output config.h instead of stamp-h. diff --git a/libiberty/functions.texi b/libiberty/functions.texi index e6ab84c69..34566d8f1 100644 --- a/libiberty/functions.texi +++ b/libiberty/functions.texi @@ -688,7 +688,9 @@ reading and writing. @c pexecute.txh:266 @deftypefn Extension void pex_free (struct pex_obj @var{obj}) -Clean up and free all data associated with @var{obj}. +Clean up and free all data associated with @var{obj}. If you have not +yet called @code{pex_get_times} or @code{pex_get_status}, this will +try to kill the subprocesses. @end deftypefn @@ -814,7 +816,7 @@ the output pipe is you, but you are blocked on the input pipe. @end deftypefn -@c pexecute.txh:272 +@c pexecute.txh:274 @deftypefn Extension {const char *} pex_one (int @var{flags}, const char *@var{executable}, char * const *@var{argv}, const char *@var{pname}, const char *@var{outname}, const char *@var{errname}, int *@var{status}, int *@var{err}) An interface to permit the easy execution of a @@ -977,7 +979,7 @@ form @code{VAR=VALUE}, with the exception of the last element that must be @end deftypefn -@c pexecute.txh:284 +@c pexecute.txh:286 @deftypefn Extension int pexecute (const char *@var{program}, char * const *@var{argv}, const char *@var{this_pname}, const char *@var{temp_base}, char **@var{errmsg_fmt}, char **@var{errmsg_arg}, int @var{flags}) This is the old interface to execute one or more programs. It is @@ -986,7 +988,7 @@ documented. @end deftypefn -@c strsignal.c:539 +@c strsignal.c:541 @deftypefn Supplemental void psignal (int @var{signo}, char *@var{message}) Print @var{message} to the standard error, followed by a colon, @@ -1005,7 +1007,7 @@ name is unset/removed. @end deftypefn -@c pexecute.txh:292 +@c pexecute.txh:294 @deftypefn Extension int pwait (int @var{pid}, int *@var{status}, int @var{flags}) Another part of the old execution interface. @@ -1256,7 +1258,7 @@ call to @code{strsignal}. @end deftypefn -@c strsignal.c:446 +@c strsignal.c:448 @deftypefn Extension {const char*} strsigno (int @var{signo}) Given an signal number, returns a pointer to a string containing the @@ -1322,7 +1324,7 @@ that the converted value is unsigned. @end deftypefn -@c strsignal.c:500 +@c strsignal.c:502 @deftypefn Extension int strtosigno (const char *@var{name}) Given the symbolic name of a signal, map it to a signal number. If no diff --git a/libiberty/make-temp-file.c b/libiberty/make-temp-file.c index 5e21414ad..94c76d700 100644 --- a/libiberty/make-temp-file.c +++ b/libiberty/make-temp-file.c @@ -23,6 +23,7 @@ Boston, MA 02110-1301, USA. */ #include /* May get P_tmpdir. */ #include +#include #ifdef HAVE_UNISTD_H #include #endif @@ -166,11 +167,14 @@ make_temp_file (const char *suffix) strcpy (temp_filename + base_len + TEMP_FILE_LEN, suffix); fd = mkstemps (temp_filename, suffix_len); - /* If mkstemps failed, then something bad is happening. Maybe we should - issue a message about a possible security attack in progress? */ + /* Mkstemps failed. It may be EPERM, ENOSPC etc. */ if (fd == -1) - abort (); - /* Similarly if we can not close the file. */ + { + fprintf (stderr, "Cannot create temporary file in %s: %s\n", + base, strerror (errno)); + abort (); + } + /* We abort on failed close out of sheer paranoia. */ if (close (fd)) abort (); return temp_filename; diff --git a/libiberty/mkstemps.c b/libiberty/mkstemps.c index 6c2e47252..093b67af8 100644 --- a/libiberty/mkstemps.c +++ b/libiberty/mkstemps.c @@ -127,6 +127,9 @@ mkstemps (char *pattern, int suffix_len) if (fd >= 0) /* The file does not exist. */ return fd; + if (errno != EEXIST) + /* Fatal error (EPERM, ENOSPC etc). Doesn't make sense to loop. */ + break; /* This is a random value. It is only necessary that the next TMP_MAX values generated by adding 7777 to VALUE are different -- 2.11.4.GIT