unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer via Libc-alpha <libc-alpha@sourceware.org>
To: libc-alpha@sourceware.org
Subject: [PATCH] libio: Deprecate the fcloseall function (bug 28099)
Date: Thu, 24 Nov 2022 17:08:32 +0100	[thread overview]
Message-ID: <877czk2v3z.fsf@oldenburg.str.redhat.com> (raw)

---
 NEWS              |  4 ++++
 libio/stdio.h     |  3 ++-
 manual/stdio.texi | 26 --------------------------
 3 files changed, 6 insertions(+), 27 deletions(-)

diff --git a/NEWS b/NEWS
index a10bb08fb0..e26bbe80b7 100644
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,10 @@ Deprecated and removed features, and other changes affecting compatibility:
   corresponds to the AT_PLATFORM system name, or employs the legacy AT_HWCAP
   search mechanism, which was deprecated in version 2.33.
 
+* The fcloseall function has been deprecated and will be removed in a
+  future release.  It does not behave as documented, and closing the
+  standard streams is unsafe.
+
 Changes to build and runtime requirements:
 
   [Add changes to build and runtime requirements here]
diff --git a/libio/stdio.h b/libio/stdio.h
index 0e0f16b464..94fca915b2 100644
--- a/libio/stdio.h
+++ b/libio/stdio.h
@@ -246,7 +246,8 @@ extern int fflush_unlocked (FILE *__stream);
    cancellation point.  But due to similarity with an POSIX interface
    or due to the implementation it is a cancellation point and
    therefore not marked with __THROW.  */
-extern int fcloseall (void);
+extern int fcloseall (void) __attribute_deprecated_msg__
+  ("Closing all streams is unsafe; consider using fflush (NULL) instead");
 #endif
 
 
diff --git a/manual/stdio.texi b/manual/stdio.texi
index 4aa1a2bc2d..22b316839b 100644
--- a/manual/stdio.texi
+++ b/manual/stdio.texi
@@ -441,32 +441,6 @@ you are using NFS.
 The function @code{fclose} is declared in @file{stdio.h}.
 @end deftypefun
 
-To close all streams currently available @theglibc{} provides
-another function.
-
-@deftypefun int fcloseall (void)
-@standards{GNU, stdio.h}
-@safety{@prelim{}@mtunsafe{@mtasurace{:streams}}@asunsafe{}@acsafe{}}
-@c Like fclose, using any previously-opened streams after fcloseall is
-@c undefined.  However, the implementation of fcloseall isn't equivalent
-@c to calling fclose for all streams: it just flushes and unbuffers all
-@c streams, without any locking.  It's the flushing without locking that
-@c makes it unsafe.
-This function causes all open streams of the process to be closed and
-the connections to corresponding files to be broken.  All buffered data
-is written and any buffered input is discarded.  The @code{fcloseall}
-function returns a value of @code{0} if all the files were closed
-successfully, and @code{EOF} if an error was detected.
-
-This function should be used only in special situations, e.g., when an
-error occurred and the program must be aborted.  Normally each single
-stream should be closed separately so that problems with individual
-streams can be identified.  It is also problematic since the standard
-streams (@pxref{Standard Streams}) will also be closed.
-
-The function @code{fcloseall} is declared in @file{stdio.h}.
-@end deftypefun
-
 If the @code{main} function to your program returns, or if you call the
 @code{exit} function (@pxref{Normal Termination}), all open streams are
 automatically closed properly.  If your program terminates in any other

base-commit: a46956e65d037358161e7512a9f0fd408ea1333a


                 reply	other threads:[~2022-11-24 16:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877czk2v3z.fsf@oldenburg.str.redhat.com \
    --to=libc-alpha@sourceware.org \
    --cc=fweimer@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).