From patchwork Thu Sep 5 21:50:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 97205 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 9F8FE384AB63 for ; Thu, 5 Sep 2024 21:51:17 +0000 (GMT) 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 ESMTP id 16E39385842D for ; Thu, 5 Sep 2024 21:50:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 16E39385842D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 16E39385842D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725573055; cv=none; b=ULtM27JtUVoi9F8kGwe4JyCXNhBBLp/trNAPORyHWL3pF7S7eo6ERKfWPwEKa+wIdtss98ktQiYppfqy7VCJvO94igNZJ3jFvFthp4/QAqxDVxCAFFAyG0RjfibNuOPH3gM3Asf1tE3DTsNpBrJVM5sdV01Tw4TwhksH/RPWvos= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725573055; c=relaxed/simple; bh=9BQU4Xy66Jje7jePzVuZaCIVxmt1U79N71o2V/ExRVE=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=Veo6DtZdhQVNgu3gYX0WZxltPNSaQaJDCUn4D8v8/9hCbHnPqbonunsDawgxLgg/yW7tkLdfD90mpfN5ZBYGsucyPDipLPebP/wbxd6GaPBizOVhmRPl6CTckard2kUkU3iBiWEERCUlV7BZJDftfZ0/xgamTgauJg6Tkf/aCgs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725573052; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=o/PJQDHXkjL3g7KJyRr8HWsznqH7E+J5L/WxInwooMw=; b=JbWjdzXOD9aqc67DwaR9bXICqgvZqsl1FyJvG7wg3kGqIu1oD1ZK5xD1gZsnFG91CAxpaX ewCDOReUaLp/uvJtV3v2GOcv5mmf8gVA85f8poU0a+Z9TlJoJ9cr1RDIU/+GJJKv8UKrb/ N6LAX+cN/ReVg90PduFJoy2TP1o1L78= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-159-iNVGD0DRPIW_SFLs8cLo3A-1; Thu, 05 Sep 2024 17:50:49 -0400 X-MC-Unique: iNVGD0DRPIW_SFLs8cLo3A-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-42bafca2438so12308155e9.3 for ; Thu, 05 Sep 2024 14:50:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725573048; x=1726177848; h=mime-version:message-id:subject:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=o/PJQDHXkjL3g7KJyRr8HWsznqH7E+J5L/WxInwooMw=; b=lRK4Yu6d7hZ84OSpSfN1FhAcgSFGkuPbkEpL11hKOAlwgh0sa+eMeOgzYtie2r9+Ae 15RGxG0WcQxITM7vSpOc7awvk2xDtPB76Xio/RMTkz5pCMlJAwGFTqUyiOm2WW566j6n jgIMF+PjDTdJXj5+Lqk8vslUAvEWuMm5mGXyJ4MxObuKkqJN9R93HIOhReYLuCYAfN4s MRItuRt+x5SzbAFc9Xnykb9Z5ClS/j4T3qv9rv5ObUxKWC7LpISaQiV1Zs8s6reJoyJh zZeZYQFWRZ8k3HDlZ3ZUiPNSuAYx4tGjWa0h7FP/VfdctbRjSprdWvUERO0t9+jFyOhB kpMA== X-Gm-Message-State: AOJu0YyJej5ygTH1b4laTevA9BN17pLlfU5NPOvQZfbyeFzu7IJfBd/r OYMxII09xDcYQakU4ihbK5HbzairvjmiZ9YknxcYXobcdt5yRexR+ifem8FeF+Nf68vDNxBCuJF A1CGyVt1FG5qWERGUHga3E4za9y8HmjxQA5kQiqwzzrDN65u76lnESJ5LdW4SqLjgZAPDxrTsMu 0LqiNGdMMLmPSftIABEPO8a67XxQx0TeLUUoZEnh9euw== X-Received: by 2002:a05:600c:1c21:b0:425:64c5:5780 with SMTP id 5b1f17b1804b1-42c9f97c827mr4425655e9.1.1725573048264; Thu, 05 Sep 2024 14:50:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF3peheodMGn1+2XO45Dt8NuX/YGLjzZBaKb3Fgl1HETv2zlRkmqfKb4TgnxAe3d/r3KmRNSw== X-Received: by 2002:a05:600c:1c21:b0:425:64c5:5780 with SMTP id 5b1f17b1804b1-42c9f97c827mr4425505e9.1.1725573047496; Thu, 05 Sep 2024 14:50:47 -0700 (PDT) Received: from digraph.polyomino.org.uk (digraph.polyomino.org.uk. [2001:8b0:bf73:93f7::51bb:e332]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-374ba3da654sm16564714f8f.89.2024.09.05.14.50.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 14:50:47 -0700 (PDT) Received: from jsm28 (helo=localhost) by digraph.polyomino.org.uk with local-esmtp (Exim 4.95) (envelope-from ) id 1smKMd-00CVlx-TG for libc-alpha@sourceware.org; Thu, 05 Sep 2024 21:50:03 +0000 Date: Thu, 5 Sep 2024 21:50:03 +0000 (UTC) From: Joseph Myers To: libc-alpha@sourceware.org Subject: Document limitations on streams passed to freopen Message-ID: <3889717-62fc-7bcb-2f3e-bde77b7a9d6a@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-9.1 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_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org As recently discussed, document that freopen does not work with streams opened with functions such as popen, fmemopen, open_memstream or fopencookie. I've filed to clarify this issue in POSIX. Tested with "make info" and "make html". diff --git a/manual/stdio.texi b/manual/stdio.texi index 29888a361f..d07b3e5ad6 100644 --- a/manual/stdio.texi +++ b/manual/stdio.texi @@ -330,6 +330,14 @@ this ability, so using @code{freopen} is more portable. When the sources are compiled with @code{_FILE_OFFSET_BITS == 64} on a 32 bit machine this function is in fact @code{freopen64} since the LFS interface replaces transparently the old interface. + +@Theglibc{} only supports use of @code{freopen} on streams opened with +@code{fopen} or @code{fopen64} and on the standard streams +@code{stdin}, @code{stdout}, and @code{stderr}; such a stream may be +reopened multiple times with @code{freopen}. If it is called on +another kind of stream (opened with functions such as @code{popen}, +@code{fmemopen}, @code{open_memstream}, and @code{fopencookie}), +@code{freopen} fails and returns a null pointer. @end deftypefun @deftypefun {FILE *} freopen64 (const char *@var{filename}, const char *@var{opentype}, FILE *@var{stream})