From patchwork Thu Nov 24 16:08:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 61087 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 57860382EF02 for ; Thu, 24 Nov 2022 16:09:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 57860382EF02 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669306142; bh=rkRGjXsT/sd6cZ7i3hiA0wIYk2hBVvMH238YB+pa0yU=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=uvuwAVY73FQVweJgS105kHyCRy6CgQ4jxZbGuNXquLmatO+9JyCqCgl770OGdJ6Tt 19XsMp3RKWOnhSr2lLneEpUh64Zuq2/ZXzAKaeAr5VZfXedvqgMF2VEDvuYALC6bNH Wq6/5kWKtEixe2zbBvw971Vx60QUIANSKrnfTjnQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id E62643830B29 for ; Thu, 24 Nov 2022 16:08:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E62643830B29 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-593-cmykCmXrNs2OR9YdjsF1bg-1; Thu, 24 Nov 2022 11:08:36 -0500 X-MC-Unique: cmykCmXrNs2OR9YdjsF1bg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6C459186E393 for ; Thu, 24 Nov 2022 16:08:36 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E26522166B26 for ; Thu, 24 Nov 2022 16:08:35 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH] libio: Deprecate the fcloseall function (bug 28099) Date: Thu, 24 Nov 2022 17:08:32 +0100 Message-ID: <877czk2v3z.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" --- NEWS | 4 ++++ libio/stdio.h | 3 ++- manual/stdio.texi | 26 -------------------------- 3 files changed, 6 insertions(+), 27 deletions(-) base-commit: a46956e65d037358161e7512a9f0fd408ea1333a 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