* [PATCH] libio: Deprecate the fcloseall function (bug 28099)
@ 2022-11-24 16:08 Florian Weimer via Libc-alpha
0 siblings, 0 replies; only message in thread
From: Florian Weimer via Libc-alpha @ 2022-11-24 16:08 UTC (permalink / raw)
To: libc-alpha
---
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-11-24 16:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-24 16:08 [PATCH] libio: Deprecate the fcloseall function (bug 28099) Florian Weimer via Libc-alpha
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).