public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR65411 don't retry fclose on EINTR
@ 2017-01-13 17:52 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2017-01-13 17:52 UTC (permalink / raw)
  To: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 303 bytes --]

After an interrupted fclose() we can't know if it's safe (or undefined
behaviour) to re-use the FILE*, so we shouldn't try calling fclose
again.

	PR libstdc++/65411
	* config/io/basic_file_stdio.cc (__basic_file<char>::close()): Don't
	retry fclose on EINTR.

Tested x86_64-linux, committed to trunk.


[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1045 bytes --]

commit 852ab4a7f7619036ddf2d7263a40368c351ff19c
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Jan 13 17:25:06 2017 +0000

    PR65411 don't retry fclose on EINTR
    
    	PR libstdc++/65411
    	* config/io/basic_file_stdio.cc (__basic_file<char>::close()): Don't
    	retry fclose on EINTR.

diff --git a/libstdc++-v3/config/io/basic_file_stdio.cc b/libstdc++-v3/config/io/basic_file_stdio.cc
index a0ad82c..e736701 100644
--- a/libstdc++-v3/config/io/basic_file_stdio.cc
+++ b/libstdc++-v3/config/io/basic_file_stdio.cc
@@ -267,16 +267,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       {
 	int __err = 0;
 	if (_M_cfile_created)
-	  {
-	    // In general, no need to zero errno in advance if checking
-	    // for error first. However, C89/C99 (at variance with IEEE
-	    // 1003.1, f.i.) do not mandate that fclose must set errno
-	    // upon error.
-	    errno = 0;
-	    do
-	      __err = fclose(_M_cfile);
-	    while (__err && errno == EINTR);
-	  }
+	  __err = fclose(_M_cfile);
 	_M_cfile = 0;
 	if (!__err)
 	  __ret = this;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-01-13 17:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-13 17:52 [PATCH] PR65411 don't retry fclose on EINTR Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).