GNU logs - #33965, boring messages


Message sent to bug-diffutils@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#33965: handling of closed file descriptors
Resent-From: Bruno Haible <bruno@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-diffutils@HIDDEN
Resent-Date: Thu, 03 Jan 2019 19:43:01 +0000
Resent-Message-ID: <handler.33965.B.154654456025733 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 33965
X-GNU-PR-Package: diffutils
X-GNU-PR-Keywords: 
To: 33965 <at> debbugs.gnu.org
X-Debbugs-Original-To: bug-diffutils@HIDDEN
Received: via spool by submit <at> debbugs.gnu.org id=B.154654456025733
          (code B ref -1); Thu, 03 Jan 2019 19:43:01 +0000
Received: (at submit) by debbugs.gnu.org; 3 Jan 2019 19:42:40 +0000
Received: from localhost ([127.0.0.1]:45978 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gf8t6-0006gz-8f
	for submit <at> debbugs.gnu.org; Thu, 03 Jan 2019 14:42:40 -0500
Received: from eggsout.gnu.org ([209.51.188.92]:54525)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <bruno@HIDDEN>) id 1gf8t3-0006gr-PG
 for submit <at> debbugs.gnu.org; Thu, 03 Jan 2019 14:42:38 -0500
Received: from lists.gnu.org ([208.118.235.17]:39561)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <bruno@HIDDEN>) id 1gf8t3-0002Ue-CC
 for submit <at> debbugs.gnu.org; Thu, 03 Jan 2019 14:42:37 -0500
Received: from eggs.gnu.org ([208.118.235.92]:54177)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <bruno@HIDDEN>) id 1gf8t2-0005nI-8s
 for bug-diffutils@HIDDEN; Thu, 03 Jan 2019 14:42:37 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled
 version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <bruno@HIDDEN>) id 1gf8t1-0002TS-7F
 for bug-diffutils@HIDDEN; Thu, 03 Jan 2019 14:42:36 -0500
Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::5]:27735)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <bruno@HIDDEN>) id 1gf8t0-0002QG-Mf
 for bug-diffutils@HIDDEN; Thu, 03 Jan 2019 14:42:35 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1546544549;
 s=strato-dkim-0002; d=clisp.org;
 h=Message-ID:Date:Subject:To:From:X-RZG-CLASS-ID:X-RZG-AUTH:From:
 Subject:Sender;
 bh=bbtcrI9mcFw+VGLtihe2kprsV78PlZcIxbhyEi0xrk8=;
 b=dvC87gTWLRV5DM3s3hnmaaj85eZUkbRsefLnZKY6nGarjgMaivaE4aNOhZjvyISUMz
 Xu5m2CrfQM0x73vp8Q6DdStWyJqu3ZF/r5/mkHjIPrcwKhxLbZuXHd0TFltC2Lt6PQTp
 aK2dKIjNGMtBQ9Gf9PNviCBRRxy4ctRzK4hrv7O8YKBWZIOs5k5ozNwZx1UGF+1mcIXd
 PTOGaOVL1WvnfYfJNtiGy5MjDj9+lr7ZKmFSUaAWYHpw4gtmb/JfNiPAoeh2McM1oR82
 ve3FZOjc5G163K6M8bOjBF/bPNNdtTy7BA/qkfTgXFmG1xB3c4SgGTBVn/FRLnJX/3q4
 DuVQ==
X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOGKf2y/s="
X-RZG-CLASS-ID: mo00
Received: from bruno.haible.de by smtp.strato.de (RZmta 44.9 DYNA|AUTH)
 with ESMTPSA id k06e80v03JgTLIm
 (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve secp521r1 with 521 ECDH
 bits, eq. 15360 bits RSA)) (Client did not present a certificate);
 Thu, 3 Jan 2019 20:42:29 +0100 (CET)
From: Bruno Haible <bruno@HIDDEN>
Date: Thu, 03 Jan 2019 20:42:28 +0100
Message-ID: <6639990.yRvKeTYcJc@omega>
User-Agent: KMail/5.1.3 (Linux/4.4.0-141-generic; KDE/5.18.0; x86_64; ; )
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="nextPart8317215.dh2gXTNRMh"
Content-Transfer-Encoding: 7Bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2a01:238:20a:202:5300::5
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

This is a multi-part message in MIME format.

--nextPart8317215.dh2gXTNRMh
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="us-ascii"

There is a problem with the handling of closed file descriptors
in diff-3.7: As mentioned in [1], the 'new-file' test fails on HP-UX.
An investigation [2] shows that different coding techniques are needed,
depending on the desired outcome for closed file descriptors.

This patch uses a variant of (A) from [2]. Namely, the result of fcntl
can apparently be used to distinguish the substitute file descriptor
stuffed in by exec() from a regular open("/dev/null",O_RDONLY).

[1] https://lists.gnu.org/archive/html/diffutils-devel/2018-12/msg00019.html
[2] https://lists.gnu.org/archive/html/bug-gnulib/2019-01/msg00012.html

--nextPart8317215.dh2gXTNRMh
Content-Disposition: attachment; filename="0001-Recognize-file-descriptors-closed-by-the-parent-proc.patch"
Content-Transfer-Encoding: 7Bit
Content-Type: text/x-patch; charset="UTF-8"; name="0001-Recognize-file-descriptors-closed-by-the-parent-proc.patch"

From 288ddc7c18c022f39233ca78e78e49e02833966c Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@HIDDEN>
Date: Thu, 3 Jan 2019 20:36:35 +0100
Subject: [PATCH] Recognize file descriptors closed by the parent process on
 HP-UX.

* src/diff.c (compare_files): Use fcntl to distinguish a file descriptor closed
by the parent parent process from a file descriptor that references /dev/null.
---
 src/diff.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/diff.c b/src/diff.c
index 6e8c6be..2ed3ae5 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -1172,6 +1172,13 @@ compare_files (struct comparison const *parent,
 	      cmp.file[f].desc = STDIN_FILENO;
 	      if (binary && ! isatty (STDIN_FILENO))
 		set_binary_mode (STDIN_FILENO, O_BINARY);
+#ifdef __hpux
+	      /* Recognize file descriptors closed by the parent on HP-UX.  */
+	      int flags = fcntl (STDIN_FILENO, F_GETFL, NULL);
+	      if (flags >= 0 && (flags & FD_CLOEXEC) != 0)
+		cmp.file[f].desc = ERRNO_ENCODE (EBADF);
+	      else
+#endif
 	      if (fstat (STDIN_FILENO, &cmp.file[f].stat) != 0)
 		cmp.file[f].desc = ERRNO_ENCODE (errno);
 	      else
-- 
2.7.4


--nextPart8317215.dh2gXTNRMh--





Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Bruno Haible <bruno@HIDDEN>
Subject: bug#33965: Acknowledgement (handling of closed file descriptors)
Message-ID: <handler.33965.B.154654456025733.ack <at> debbugs.gnu.org>
References: <6639990.yRvKeTYcJc@omega>
X-Gnu-PR-Message: ack 33965
X-Gnu-PR-Package: diffutils
Reply-To: 33965 <at> debbugs.gnu.org
Date: Thu, 03 Jan 2019 19:43:04 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

Your message has been sent to the package maintainer(s):
 bug-diffutils@HIDDEN

If you wish to submit further information on this problem, please
send it to 33965 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
33965: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D33965
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems


Message sent to bug-diffutils@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#33965: handling of closed file descriptors
Resent-From: Bruno Haible <bruno@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-diffutils@HIDDEN
Resent-Date: Thu, 03 Jan 2019 20:03:02 +0000
Resent-Message-ID: <handler.33965.B.154654574327649 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 33965
X-GNU-PR-Package: diffutils
X-GNU-PR-Keywords: 
To: 33965 <at> debbugs.gnu.org
X-Debbugs-Original-To: bug-diffutils@HIDDEN
Received: via spool by submit <at> debbugs.gnu.org id=B.154654574327649
          (code B ref -1); Thu, 03 Jan 2019 20:03:02 +0000
Received: (at submit) by debbugs.gnu.org; 3 Jan 2019 20:02:23 +0000
Received: from localhost ([127.0.0.1]:45983 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gf9CB-0007Bs-0C
	for submit <at> debbugs.gnu.org; Thu, 03 Jan 2019 15:02:23 -0500
Received: from eggs.gnu.org ([208.118.235.92]:60193)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <bruno@HIDDEN>) id 1gf9C8-0007Bk-AY
 for submit <at> debbugs.gnu.org; Thu, 03 Jan 2019 15:02:21 -0500
Received: from lists.gnu.org ([208.118.235.17]:56379)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <bruno@HIDDEN>) id 1gf9C8-0005eT-5L
 for submit <at> debbugs.gnu.org; Thu, 03 Jan 2019 15:02:20 -0500
Received: from eggs.gnu.org ([208.118.235.92]:59000)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <bruno@HIDDEN>) id 1gf9C7-0001rP-E5
 for bug-diffutils@HIDDEN; Thu, 03 Jan 2019 15:02:20 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled
 version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <bruno@HIDDEN>) id 1gf9C6-0005da-N6
 for bug-diffutils@HIDDEN; Thu, 03 Jan 2019 15:02:19 -0500
Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::6]:29686)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <bruno@HIDDEN>) id 1gf9C6-0005cd-6K
 for bug-diffutils@HIDDEN; Thu, 03 Jan 2019 15:02:18 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1546545736;
 s=strato-dkim-0002; d=clisp.org;
 h=References:In-Reply-To:Message-ID:Date:Subject:To:From:
 X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender;
 bh=79sr3y1MmGIeyUSoORFJ9lk3S+H8Fvt2HPsNavAq95Q=;
 b=N1EVZUB2ksQt7EGQPtdH0J4YqBf6OBioxAMAtQ4RC46UnVyjTttQE5bd0AfCrsxsbp
 8g9/WAvqIo3m9/REGJu4ur+DU55lK9CK8ddAIX1Dbfw5s57UyEUB43bmqURJUSX7xftg
 xc1vGJ9VHeFTnTKN1fwCjdySWixbE34UaMviRsJRHIgsFeIwfcxOBrl/qUFm0glE5/Ya
 Nf/PAOHzNVmmYYGFt5y1G8zbON5ds6yhFFIMFS377NbVnunFZOmtBY8IooAZeZMYbjPl
 4viNRO1VJURJNt+drG67FDGz6KaaLkhIlCWPL8J8Hbb+NCWToaDzw+ij7Y28tviCWPc2
 KGag==
X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOGKf2y/s="
X-RZG-CLASS-ID: mo00
Received: from bruno.haible.de by smtp.strato.de (RZmta 44.9 DYNA|AUTH)
 with ESMTPSA id k06e80v03K2GLKy
 (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve secp521r1 with 521 ECDH
 bits, eq. 15360 bits RSA)) (Client did not present a certificate);
 Thu, 3 Jan 2019 21:02:16 +0100 (CET)
From: Bruno Haible <bruno@HIDDEN>
Date: Thu, 03 Jan 2019 21:02:16 +0100
Message-ID: <64441865.ngSBGZCanV@omega>
User-Agent: KMail/5.1.3 (Linux/4.4.0-141-generic; KDE/5.18.0; x86_64; ; )
In-Reply-To: <6639990.yRvKeTYcJc@omega>
References: <6639990.yRvKeTYcJc@omega>
MIME-Version: 1.0
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="us-ascii"
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2a01:238:20a:202:5300::6
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Spam-Score: -5.0 (-----)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -6.0 (------)

I wrote:
> the result of fcntl
> can apparently be used to distinguish the substitute file descriptor
> stuffed in by exec() from a regular open("/dev/null",O_RDONLY).

Note that the code works for STDIN_FILENO, where fcntl(...) is 5 in one case
and 0 in the other case, and we use FD_CLOEXEC = 1 to distinguish the two.
For STDOUT_FILENO, fcntl(...) would be 5 in one case and 1 in the other case,
and the flag which allows to distinguish the two cases (4) is not listed in
<sys/fcntl.h>, therefore likely is a kernel-private flag.

Bruno





Message sent:


MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Jim Meyering <jim@HIDDEN>
Subject: bug#33965: closed (handling of closed file descriptors)
CC: tracker <at> debbugs.gnu.org
Message-ID: <handler.33965.D33965.154658253930289.ackdone <at> debbugs.gnu.org>
References: <CA+8g5KEe5CDHBKFqUgEUTV6saK2XDSn2_SVPQp_U53SRMABDWA@HIDDEN>
 <6639990.yRvKeTYcJc@omega>
X-Gnu-PR-Message: closed 33965
X-Gnu-PR-Package: diffutils
Date: Fri, 04 Jan 2019 06:16:02 +0000
Content-Type: multipart/mixed; boundary="----------=_1546582562-31401-0"

This is a multi-part message in MIME format...

------------=_1546582562-31401-0
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=utf-8

Your message dated Thu, 3 Jan 2019 22:15:19 -0800
with message-id <CA+8g5KEe5CDHBKFqUgEUTV6saK2XDSn2_SVPQp_U53SRMABDWA@HIDDEN=
mail.com>
and subject line Re: [bug-diffutils] bug#33965: handling of closed file des=
criptors
has caused the debbugs.gnu.org bug report #33965,
regarding handling of closed file descriptors
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@HIDDEN)


--=20
33965: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D33965
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems

------------=_1546582562-31401-0
Content-Type: message/rfc822
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

Received: (at submit) by debbugs.gnu.org; 3 Jan 2019 19:42:40 +0000
Received: from localhost ([127.0.0.1]:45978 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gf8t6-0006gz-8f
	for submit <at> debbugs.gnu.org; Thu, 03 Jan 2019 14:42:40 -0500
Received: from eggsout.gnu.org ([209.51.188.92]:54525)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <bruno@HIDDEN>) id 1gf8t3-0006gr-PG
 for submit <at> debbugs.gnu.org; Thu, 03 Jan 2019 14:42:38 -0500
Received: from lists.gnu.org ([208.118.235.17]:39561)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <bruno@HIDDEN>) id 1gf8t3-0002Ue-CC
 for submit <at> debbugs.gnu.org; Thu, 03 Jan 2019 14:42:37 -0500
Received: from eggs.gnu.org ([208.118.235.92]:54177)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <bruno@HIDDEN>) id 1gf8t2-0005nI-8s
 for bug-diffutils@HIDDEN; Thu, 03 Jan 2019 14:42:37 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled
 version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <bruno@HIDDEN>) id 1gf8t1-0002TS-7F
 for bug-diffutils@HIDDEN; Thu, 03 Jan 2019 14:42:36 -0500
Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::5]:27735)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <bruno@HIDDEN>) id 1gf8t0-0002QG-Mf
 for bug-diffutils@HIDDEN; Thu, 03 Jan 2019 14:42:35 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1546544549;
 s=strato-dkim-0002; d=clisp.org;
 h=Message-ID:Date:Subject:To:From:X-RZG-CLASS-ID:X-RZG-AUTH:From:
 Subject:Sender;
 bh=bbtcrI9mcFw+VGLtihe2kprsV78PlZcIxbhyEi0xrk8=;
 b=dvC87gTWLRV5DM3s3hnmaaj85eZUkbRsefLnZKY6nGarjgMaivaE4aNOhZjvyISUMz
 Xu5m2CrfQM0x73vp8Q6DdStWyJqu3ZF/r5/mkHjIPrcwKhxLbZuXHd0TFltC2Lt6PQTp
 aK2dKIjNGMtBQ9Gf9PNviCBRRxy4ctRzK4hrv7O8YKBWZIOs5k5ozNwZx1UGF+1mcIXd
 PTOGaOVL1WvnfYfJNtiGy5MjDj9+lr7ZKmFSUaAWYHpw4gtmb/JfNiPAoeh2McM1oR82
 ve3FZOjc5G163K6M8bOjBF/bPNNdtTy7BA/qkfTgXFmG1xB3c4SgGTBVn/FRLnJX/3q4
 DuVQ==
X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOGKf2y/s="
X-RZG-CLASS-ID: mo00
Received: from bruno.haible.de by smtp.strato.de (RZmta 44.9 DYNA|AUTH)
 with ESMTPSA id k06e80v03JgTLIm
 (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve secp521r1 with 521 ECDH
 bits, eq. 15360 bits RSA)) (Client did not present a certificate);
 Thu, 3 Jan 2019 20:42:29 +0100 (CET)
From: Bruno Haible <bruno@HIDDEN>
To: bug-diffutils@HIDDEN
Subject: handling of closed file descriptors
Date: Thu, 03 Jan 2019 20:42:28 +0100
Message-ID: <6639990.yRvKeTYcJc@omega>
User-Agent: KMail/5.1.3 (Linux/4.4.0-141-generic; KDE/5.18.0; x86_64; ; )
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="nextPart8317215.dh2gXTNRMh"
Content-Transfer-Encoding: 7Bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2a01:238:20a:202:5300::5
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

This is a multi-part message in MIME format.

--nextPart8317215.dh2gXTNRMh
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="us-ascii"

There is a problem with the handling of closed file descriptors
in diff-3.7: As mentioned in [1], the 'new-file' test fails on HP-UX.
An investigation [2] shows that different coding techniques are needed,
depending on the desired outcome for closed file descriptors.

This patch uses a variant of (A) from [2]. Namely, the result of fcntl
can apparently be used to distinguish the substitute file descriptor
stuffed in by exec() from a regular open("/dev/null",O_RDONLY).

[1] https://lists.gnu.org/archive/html/diffutils-devel/2018-12/msg00019.html
[2] https://lists.gnu.org/archive/html/bug-gnulib/2019-01/msg00012.html

--nextPart8317215.dh2gXTNRMh
Content-Disposition: attachment; filename="0001-Recognize-file-descriptors-closed-by-the-parent-proc.patch"
Content-Transfer-Encoding: 7Bit
Content-Type: text/x-patch; charset="UTF-8"; name="0001-Recognize-file-descriptors-closed-by-the-parent-proc.patch"

From 288ddc7c18c022f39233ca78e78e49e02833966c Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@HIDDEN>
Date: Thu, 3 Jan 2019 20:36:35 +0100
Subject: [PATCH] Recognize file descriptors closed by the parent process on
 HP-UX.

* src/diff.c (compare_files): Use fcntl to distinguish a file descriptor closed
by the parent parent process from a file descriptor that references /dev/null.
---
 src/diff.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/diff.c b/src/diff.c
index 6e8c6be..2ed3ae5 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -1172,6 +1172,13 @@ compare_files (struct comparison const *parent,
 	      cmp.file[f].desc = STDIN_FILENO;
 	      if (binary && ! isatty (STDIN_FILENO))
 		set_binary_mode (STDIN_FILENO, O_BINARY);
+#ifdef __hpux
+	      /* Recognize file descriptors closed by the parent on HP-UX.  */
+	      int flags = fcntl (STDIN_FILENO, F_GETFL, NULL);
+	      if (flags >= 0 && (flags & FD_CLOEXEC) != 0)
+		cmp.file[f].desc = ERRNO_ENCODE (EBADF);
+	      else
+#endif
 	      if (fstat (STDIN_FILENO, &cmp.file[f].stat) != 0)
 		cmp.file[f].desc = ERRNO_ENCODE (errno);
 	      else
-- 
2.7.4


--nextPart8317215.dh2gXTNRMh--




------------=_1546582562-31401-0
Content-Type: message/rfc822
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

Received: (at 33965-done) by debbugs.gnu.org; 4 Jan 2019 06:15:39 +0000
Received: from localhost ([127.0.0.1]:46164 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gfIlf-0007sB-14
	for submit <at> debbugs.gnu.org; Fri, 04 Jan 2019 01:15:39 -0500
Received: from mail-wm1-f42.google.com ([209.85.128.42]:40473)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <meyering@HIDDEN>) id 1gfIld-0007lo-3k
 for 33965-done <at> debbugs.gnu.org; Fri, 04 Jan 2019 01:15:37 -0500
Received: by mail-wm1-f42.google.com with SMTP id f188so225531wmf.5
 for <33965-done <at> debbugs.gnu.org>; Thu, 03 Jan 2019 22:15:37 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:references:in-reply-to:from:date
 :message-id:subject:to:cc;
 bh=a4MlZlzjJ5MGW9dldKf2Oc79zPcg/IGWqtyl84K3mjI=;
 b=Vgz2z0zEkQSuXqcudLs5E/BRqBNHQgejih9Ffa24lwXtNFKiZ8fb1sMVAVg6zoKMl7
 eeONfe8SRUZJctNL4VLzI31q7MmiiFUWkCC8oeKuTuO4A330jrZrOvFpbu5MT2VRGhR0
 w9VetFbBlFa+jpjy15Jlr+G9GiQMnlPb/q1kjfLUftU83QBAOMSXXzz0w5BwtBv2qK1F
 2fx8gh/7qC3o7qR9lUEcR+bHAhgU7QjCUJ3lW11nI2G2vtf84xoEwAWJTltr+fCjjlu3
 OnlzsPpmQb9CL9lJyj4UL6qIPvlUXvXfvSxNkTsAMxo3idO139qB2cpFWGxkb0lFGJMV
 9LMw==
X-Gm-Message-State: AJcUukfW+sfD0+C8J5uUvE2Ws53iEqzEwVvph/iuptlW5sZC71yoICzS
 68oPptSPtroguXjwGNVj3My8VleY22peHYE+zPA=
X-Google-Smtp-Source: ALg8bN4nBAcsKqeVr8UOl8K8nFBi4mgl9sUySVCy3Al7Z9ZpfNFZ6cxYxfnLxp8hnGfzRD/mqQN4hNlTLGBodTMJ4hM=
X-Received: by 2002:a1c:4346:: with SMTP id q67mr347065wma.114.1546582531343; 
 Thu, 03 Jan 2019 22:15:31 -0800 (PST)
MIME-Version: 1.0
References: <6639990.yRvKeTYcJc@omega>
In-Reply-To: <6639990.yRvKeTYcJc@omega>
From: Jim Meyering <jim@HIDDEN>
Date: Thu, 3 Jan 2019 22:15:19 -0800
Message-ID: <CA+8g5KEe5CDHBKFqUgEUTV6saK2XDSn2_SVPQp_U53SRMABDWA@HIDDEN>
Subject: Re: [bug-diffutils] bug#33965: handling of closed file descriptors
To: Bruno Haible <bruno@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 33965-done
Cc: 33965-done <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On Thu, Jan 3, 2019 at 11:43 AM Bruno Haible <bruno@HIDDEN> wrote:
>
> There is a problem with the handling of closed file descriptors
> in diff-3.7: As mentioned in [1], the 'new-file' test fails on HP-UX.
> An investigation [2] shows that different coding techniques are needed,
> depending on the desired outcome for closed file descriptors.
>
> This patch uses a variant of (A) from [2]. Namely, the result of fcntl
> can apparently be used to distinguish the substitute file descriptor
> stuffed in by exec() from a regular open("/dev/null",O_RDONLY).
>
> [1] https://lists.gnu.org/archive/html/diffutils-devel/2018-12/msg00019.html
> [2] https://lists.gnu.org/archive/html/bug-gnulib/2019-01/msg00012.html

Thank you. I have just pushed that with one tweak to the log message:
s/parent parent/parent/.


------------=_1546582562-31401-0--


Message sent:


MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Bruno Haible <bruno@HIDDEN>
Subject: bug#33965: closed (Re: [bug-diffutils] bug#33965: handling of
 closed file descriptors)
Message-ID: <handler.33965.D33965.154658253930289.notifdone <at> debbugs.gnu.org>
References: <CA+8g5KEe5CDHBKFqUgEUTV6saK2XDSn2_SVPQp_U53SRMABDWA@HIDDEN>
 <6639990.yRvKeTYcJc@omega>
X-Gnu-PR-Message: they-closed 33965
X-Gnu-PR-Package: diffutils
Reply-To: 33965 <at> debbugs.gnu.org
Date: Fri, 04 Jan 2019 06:16:02 +0000
Content-Type: multipart/mixed; boundary="----------=_1546582562-31401-1"

This is a multi-part message in MIME format...

------------=_1546582562-31401-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset="utf-8"

Your bug report

#33965: handling of closed file descriptors

which was filed against the diffutils package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 33965 <at> debbugs.gnu.org.

--=20
33965: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D33965
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems

------------=_1546582562-31401-1
Content-Type: message/rfc822
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

Received: (at 33965-done) by debbugs.gnu.org; 4 Jan 2019 06:15:39 +0000
Received: from localhost ([127.0.0.1]:46164 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gfIlf-0007sB-14
	for submit <at> debbugs.gnu.org; Fri, 04 Jan 2019 01:15:39 -0500
Received: from mail-wm1-f42.google.com ([209.85.128.42]:40473)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <meyering@HIDDEN>) id 1gfIld-0007lo-3k
 for 33965-done <at> debbugs.gnu.org; Fri, 04 Jan 2019 01:15:37 -0500
Received: by mail-wm1-f42.google.com with SMTP id f188so225531wmf.5
 for <33965-done <at> debbugs.gnu.org>; Thu, 03 Jan 2019 22:15:37 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:references:in-reply-to:from:date
 :message-id:subject:to:cc;
 bh=a4MlZlzjJ5MGW9dldKf2Oc79zPcg/IGWqtyl84K3mjI=;
 b=Vgz2z0zEkQSuXqcudLs5E/BRqBNHQgejih9Ffa24lwXtNFKiZ8fb1sMVAVg6zoKMl7
 eeONfe8SRUZJctNL4VLzI31q7MmiiFUWkCC8oeKuTuO4A330jrZrOvFpbu5MT2VRGhR0
 w9VetFbBlFa+jpjy15Jlr+G9GiQMnlPb/q1kjfLUftU83QBAOMSXXzz0w5BwtBv2qK1F
 2fx8gh/7qC3o7qR9lUEcR+bHAhgU7QjCUJ3lW11nI2G2vtf84xoEwAWJTltr+fCjjlu3
 OnlzsPpmQb9CL9lJyj4UL6qIPvlUXvXfvSxNkTsAMxo3idO139qB2cpFWGxkb0lFGJMV
 9LMw==
X-Gm-Message-State: AJcUukfW+sfD0+C8J5uUvE2Ws53iEqzEwVvph/iuptlW5sZC71yoICzS
 68oPptSPtroguXjwGNVj3My8VleY22peHYE+zPA=
X-Google-Smtp-Source: ALg8bN4nBAcsKqeVr8UOl8K8nFBi4mgl9sUySVCy3Al7Z9ZpfNFZ6cxYxfnLxp8hnGfzRD/mqQN4hNlTLGBodTMJ4hM=
X-Received: by 2002:a1c:4346:: with SMTP id q67mr347065wma.114.1546582531343; 
 Thu, 03 Jan 2019 22:15:31 -0800 (PST)
MIME-Version: 1.0
References: <6639990.yRvKeTYcJc@omega>
In-Reply-To: <6639990.yRvKeTYcJc@omega>
From: Jim Meyering <jim@HIDDEN>
Date: Thu, 3 Jan 2019 22:15:19 -0800
Message-ID: <CA+8g5KEe5CDHBKFqUgEUTV6saK2XDSn2_SVPQp_U53SRMABDWA@HIDDEN>
Subject: Re: [bug-diffutils] bug#33965: handling of closed file descriptors
To: Bruno Haible <bruno@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 33965-done
Cc: 33965-done <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On Thu, Jan 3, 2019 at 11:43 AM Bruno Haible <bruno@HIDDEN> wrote:
>
> There is a problem with the handling of closed file descriptors
> in diff-3.7: As mentioned in [1], the 'new-file' test fails on HP-UX.
> An investigation [2] shows that different coding techniques are needed,
> depending on the desired outcome for closed file descriptors.
>
> This patch uses a variant of (A) from [2]. Namely, the result of fcntl
> can apparently be used to distinguish the substitute file descriptor
> stuffed in by exec() from a regular open("/dev/null",O_RDONLY).
>
> [1] https://lists.gnu.org/archive/html/diffutils-devel/2018-12/msg00019.html
> [2] https://lists.gnu.org/archive/html/bug-gnulib/2019-01/msg00012.html

Thank you. I have just pushed that with one tweak to the log message:
s/parent parent/parent/.


------------=_1546582562-31401-1
Content-Type: message/rfc822
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

Received: (at submit) by debbugs.gnu.org; 3 Jan 2019 19:42:40 +0000
Received: from localhost ([127.0.0.1]:45978 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gf8t6-0006gz-8f
	for submit <at> debbugs.gnu.org; Thu, 03 Jan 2019 14:42:40 -0500
Received: from eggsout.gnu.org ([209.51.188.92]:54525)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <bruno@HIDDEN>) id 1gf8t3-0006gr-PG
 for submit <at> debbugs.gnu.org; Thu, 03 Jan 2019 14:42:38 -0500
Received: from lists.gnu.org ([208.118.235.17]:39561)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <bruno@HIDDEN>) id 1gf8t3-0002Ue-CC
 for submit <at> debbugs.gnu.org; Thu, 03 Jan 2019 14:42:37 -0500
Received: from eggs.gnu.org ([208.118.235.92]:54177)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <bruno@HIDDEN>) id 1gf8t2-0005nI-8s
 for bug-diffutils@HIDDEN; Thu, 03 Jan 2019 14:42:37 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled
 version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <bruno@HIDDEN>) id 1gf8t1-0002TS-7F
 for bug-diffutils@HIDDEN; Thu, 03 Jan 2019 14:42:36 -0500
Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::5]:27735)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <bruno@HIDDEN>) id 1gf8t0-0002QG-Mf
 for bug-diffutils@HIDDEN; Thu, 03 Jan 2019 14:42:35 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1546544549;
 s=strato-dkim-0002; d=clisp.org;
 h=Message-ID:Date:Subject:To:From:X-RZG-CLASS-ID:X-RZG-AUTH:From:
 Subject:Sender;
 bh=bbtcrI9mcFw+VGLtihe2kprsV78PlZcIxbhyEi0xrk8=;
 b=dvC87gTWLRV5DM3s3hnmaaj85eZUkbRsefLnZKY6nGarjgMaivaE4aNOhZjvyISUMz
 Xu5m2CrfQM0x73vp8Q6DdStWyJqu3ZF/r5/mkHjIPrcwKhxLbZuXHd0TFltC2Lt6PQTp
 aK2dKIjNGMtBQ9Gf9PNviCBRRxy4ctRzK4hrv7O8YKBWZIOs5k5ozNwZx1UGF+1mcIXd
 PTOGaOVL1WvnfYfJNtiGy5MjDj9+lr7ZKmFSUaAWYHpw4gtmb/JfNiPAoeh2McM1oR82
 ve3FZOjc5G163K6M8bOjBF/bPNNdtTy7BA/qkfTgXFmG1xB3c4SgGTBVn/FRLnJX/3q4
 DuVQ==
X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOGKf2y/s="
X-RZG-CLASS-ID: mo00
Received: from bruno.haible.de by smtp.strato.de (RZmta 44.9 DYNA|AUTH)
 with ESMTPSA id k06e80v03JgTLIm
 (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve secp521r1 with 521 ECDH
 bits, eq. 15360 bits RSA)) (Client did not present a certificate);
 Thu, 3 Jan 2019 20:42:29 +0100 (CET)
From: Bruno Haible <bruno@HIDDEN>
To: bug-diffutils@HIDDEN
Subject: handling of closed file descriptors
Date: Thu, 03 Jan 2019 20:42:28 +0100
Message-ID: <6639990.yRvKeTYcJc@omega>
User-Agent: KMail/5.1.3 (Linux/4.4.0-141-generic; KDE/5.18.0; x86_64; ; )
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="nextPart8317215.dh2gXTNRMh"
Content-Transfer-Encoding: 7Bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2a01:238:20a:202:5300::5
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

This is a multi-part message in MIME format.

--nextPart8317215.dh2gXTNRMh
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="us-ascii"

There is a problem with the handling of closed file descriptors
in diff-3.7: As mentioned in [1], the 'new-file' test fails on HP-UX.
An investigation [2] shows that different coding techniques are needed,
depending on the desired outcome for closed file descriptors.

This patch uses a variant of (A) from [2]. Namely, the result of fcntl
can apparently be used to distinguish the substitute file descriptor
stuffed in by exec() from a regular open("/dev/null",O_RDONLY).

[1] https://lists.gnu.org/archive/html/diffutils-devel/2018-12/msg00019.html
[2] https://lists.gnu.org/archive/html/bug-gnulib/2019-01/msg00012.html

--nextPart8317215.dh2gXTNRMh
Content-Disposition: attachment; filename="0001-Recognize-file-descriptors-closed-by-the-parent-proc.patch"
Content-Transfer-Encoding: 7Bit
Content-Type: text/x-patch; charset="UTF-8"; name="0001-Recognize-file-descriptors-closed-by-the-parent-proc.patch"

From 288ddc7c18c022f39233ca78e78e49e02833966c Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@HIDDEN>
Date: Thu, 3 Jan 2019 20:36:35 +0100
Subject: [PATCH] Recognize file descriptors closed by the parent process on
 HP-UX.

* src/diff.c (compare_files): Use fcntl to distinguish a file descriptor closed
by the parent parent process from a file descriptor that references /dev/null.
---
 src/diff.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/diff.c b/src/diff.c
index 6e8c6be..2ed3ae5 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -1172,6 +1172,13 @@ compare_files (struct comparison const *parent,
 	      cmp.file[f].desc = STDIN_FILENO;
 	      if (binary && ! isatty (STDIN_FILENO))
 		set_binary_mode (STDIN_FILENO, O_BINARY);
+#ifdef __hpux
+	      /* Recognize file descriptors closed by the parent on HP-UX.  */
+	      int flags = fcntl (STDIN_FILENO, F_GETFL, NULL);
+	      if (flags >= 0 && (flags & FD_CLOEXEC) != 0)
+		cmp.file[f].desc = ERRNO_ENCODE (EBADF);
+	      else
+#endif
 	      if (fstat (STDIN_FILENO, &cmp.file[f].stat) != 0)
 		cmp.file[f].desc = ERRNO_ENCODE (errno);
 	      else
-- 
2.7.4


--nextPart8317215.dh2gXTNRMh--




------------=_1546582562-31401-1--


Message sent to bug-diffutils@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#33965: [bug-diffutils] bug#33965: bug#33965: handling of closed file descriptors
Resent-From: Paul Eggert <eggert@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-diffutils@HIDDEN
Resent-Date: Fri, 04 Jan 2019 22:43:02 +0000
Resent-Message-ID: <handler.33965.B33965.154664175220116 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 33965
X-GNU-PR-Package: diffutils
X-GNU-PR-Keywords: 
To: 33965 <at> debbugs.gnu.org, jim@HIDDEN, bruno@HIDDEN
Received: via spool by 33965-submit <at> debbugs.gnu.org id=B33965.154664175220116
          (code B ref 33965); Fri, 04 Jan 2019 22:43:02 +0000
Received: (at 33965) by debbugs.gnu.org; 4 Jan 2019 22:42:32 +0000
Received: from localhost ([127.0.0.1]:47102 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gfYAi-0005EO-2d
	for submit <at> debbugs.gnu.org; Fri, 04 Jan 2019 17:42:32 -0500
Received: from zimbra.cs.ucla.edu ([131.179.128.68]:39778)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eggert@HIDDEN>) id 1gfYAf-0005E8-2k
 for 33965 <at> debbugs.gnu.org; Fri, 04 Jan 2019 17:42:30 -0500
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id E7BAD160F5B;
 Fri,  4 Jan 2019 14:42:22 -0800 (PST)
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032)
 with ESMTP id 4lGmXO5PkIEK; Fri,  4 Jan 2019 14:42:22 -0800 (PST)
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id EBBAC160F5C;
 Fri,  4 Jan 2019 14:42:21 -0800 (PST)
X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id lhaMMLX6czO2; Fri,  4 Jan 2019 14:42:21 -0800 (PST)
Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200])
 by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id CB8C1160F57;
 Fri,  4 Jan 2019 14:42:21 -0800 (PST)
From: Paul Eggert <eggert@HIDDEN>
References: <6639990.yRvKeTYcJc@omega>
 <CA+8g5KEe5CDHBKFqUgEUTV6saK2XDSn2_SVPQp_U53SRMABDWA@HIDDEN>
Openpgp: preference=signencrypt
Autocrypt: addr=eggert@HIDDEN; prefer-encrypt=mutual; keydata=
 xsFNBEyAcmQBEADAAyH2xoTu7ppG5D3a8FMZEon74dCvc4+q1XA2J2tBy2pwaTqfhpxxdGA9
 Jj50UJ3PD4bSUEgN8tLZ0san47l5XTAFLi2456ciSl5m8sKaHlGdt9XmAAtmXqeZVIYX/UFS
 96fDzf4xhEmm/y7LbYEPQdUdxu47xA5KhTYp5bltF3WYDz1Ygd7gx07Auwp7iw7eNvnoDTAl
 KAl8KYDZzbDNCQGEbpY3ef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VOEryO7QRCCYah3oxSG38IAnNeiwJXgU9Bzkk85UGbPEd7HGF
 /VSeHCQwWou6jqUDTSDvn9YhNTdG0KXPM74aC+xr2Zow1O2mhXihgWKD0Dw+0LYPnUOsQ0KO
 FxHXXYHmRrS1OZPU59BLvc+TRhIhafSHKLwbXK+6ckkxBx6h8z5ccpG0Qs4bFhdFYnFrEieD
 LoGmnE2YLhdV6swJ9VNCS6pLiEohT3fm7aXm15tZOIyzMZhHRSAPblXxQ0ZSWjq8oRrcYNFx
 c4W1URpAkBCOYJoXvQfD5L3lqAl8TCqDUzYxhH/tJhbDdHrqHH767jaDaTB1+Talp/2AMKwc
 XNOdiklGxbmHVG6YGl6g8Lrbsu9NZEI4yLlHzuikthJWgz+3vZhVGyNlt+HNIoF6CjDL2omu
 5cEq4RDHM44QqPk6l7O0pUvN1mT4B+S1b08RKpqm/ff015E37HNV/piIvJlxGAYz8PSfuGCB
 1thMYqlmgdhd9/BabGFbGGYHA6U4/T5zqU+f6xHy1SsAQZ1MSKlLwekBIT+4/cLRGqCHjnV0
 q5H/T6a7t5mPkbzSrOLSo4puj+IToNjYyYIDBWzhlA19avOa+rvUjmHtD3sFN7cXWtkGoi8b
 uNcby4U=
Organization: UCLA Computer Science Department
Message-ID: <5640e0dc-e97f-fc77-0087-9dbc8c506dc5@HIDDEN>
Date: Fri, 4 Jan 2019 14:42:21 -0800
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101
 Thunderbird/60.3.1
MIME-Version: 1.0
In-Reply-To: <CA+8g5KEe5CDHBKFqUgEUTV6saK2XDSn2_SVPQp_U53SRMABDWA@HIDDEN>
Content-Type: multipart/mixed; boundary="------------4C5C8295E10957DE69AEE802"
Content-Language: en-US
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

This is a multi-part message in MIME format.
--------------4C5C8295E10957DE69AEE802
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit

I'd rather think of this as a bug in the test case, not a bug in 'diff'. 
This is because the test case assumes more about the shell's "<&-" 
construct than what POSIX requires.

The bigger picture here is that invoking programs with stdin closed is 
trouble, and although Gnulib provides several modules to work around the 
trouble these modules are a hassle and many applications don't use them. 
We should encourage platforms like HP-UX that try to work around the 
trouble, instead of having diffutils attempt to simulate the traditional 
but inferior exec semantics. Although the Linux kernel currently 
implements the traditional semantics, in this particular case I think 
I'd rather have diffutils adjust to what the platform provides, rather 
than attempt to simulate Linux behavior even on non-Linux kernels.

So I propose the attached further patch.

--------------4C5C8295E10957DE69AEE802
Content-Type: text/plain; charset=UTF-8;
 name="0001-diff-move-HP-UX-workaround-into-test-case.txt"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename="0001-diff-move-HP-UX-workaround-into-test-case.txt"

RnJvbSBmZDNjOTc4ZGQ5Mjk0NTNkZmJlMGJmOGVhYTkyOTUzMjEyNzRiYTMzIE1vbiBTZXAg
MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBQYXVsIEVnZ2VydCA8ZWdnZXJ0QGNzLnVjbGEuZWR1
PgpEYXRlOiBGcmksIDQgSmFuIDIwMTkg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ICBjb21wYXJlIGV4cCBvdXQgfHwgZmFpbD0xCiAKLSMg
V2l0aCBjbG9zZWQgc3RhbmRhcmQgaW5wdXQsIHJlcXVpcmUgYW4gZXhpdCBzdGF0dXMgb2Yg
MgotIyBhbmQgZW1wdHkgc3Rkb3V0LgotcmV0dXJuc18gMiBkaWZmIC0tdW5pZGlyZWN0aW9u
YWwtbmV3LWZpbGUgYSAtIDwmLSA+IG91dCB8fCBmYWlsPTEKLWNvbXBhcmUgL2Rldi9udWxs
IG91dCB8fCBmYWlsPTEKKyAgIyBXaXRoIGNsb3NlZCBzdGFuZGFyZCBpbnB1dCwgcmVxdWly
ZSBhbiBleGl0IHN0YXR1cyBvZiAyCisgICMgYW5kIGVtcHR5IHN0ZG91dC4KKyAgcmV0dXJu
c18gMiBkaWZmIC0tdW5pZGlyZWN0aW9uYWwtbmV3LWZpbGUgYSAtIDwmLSA+IG91dCB8fCBm
YWlsPTEKKyAgY29tcGFyZSAvZGV2L251bGwgb3V0IHx8IGZhaWw9MQorZmkKIAogcmV0dXJu
c18gMSBkaWZmIC1OIC0gYiA8IGEgPiBvdXQgfHwgZmFpbD0xCiBjb21wYXJlIGV4cCBvdXQg
fHwgZmFpbD0xCi0tIAoyLjIwLjEKCg==
--------------4C5C8295E10957DE69AEE802--




Message received at fakecontrol@fakecontrolmessage:


Received: (at fakecontrol) by fakecontrolmessage;
To: internal_control <at> debbugs.gnu.org
From: Debbugs Internal Request <help-debbugs@HIDDEN>
Subject: Internal Control
Message-Id: Did not alter fixed versions and reopened.
Date: Fri, 04 Jan 2019 22:52:01 +0000
User-Agent: Fakemail v42.6.9

# This is a fake control message.
#
# The action:
# Did not alter fixed versions and reopened.
thanks
# This fakemail brought to you by your local debbugs
# administrator


Message sent to bug-diffutils@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#33965: [bug-diffutils] bug#33965: handling of closed file descriptors
Resent-From: Bruno Haible <bruno@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-diffutils@HIDDEN
Resent-Date: Fri, 04 Jan 2019 23:31:02 +0000
Resent-Message-ID: <handler.33965.B33965.154664465032659 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 33965
X-GNU-PR-Package: diffutils
X-GNU-PR-Keywords: 
To: Paul Eggert <eggert@HIDDEN>
Cc: 33965 <at> debbugs.gnu.org, jim@HIDDEN
Received: via spool by 33965-submit <at> debbugs.gnu.org id=B33965.154664465032659
          (code B ref 33965); Fri, 04 Jan 2019 23:31:02 +0000
Received: (at 33965) by debbugs.gnu.org; 4 Jan 2019 23:30:50 +0000
Received: from localhost ([127.0.0.1]:47116 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gfYvR-0008Uf-JJ
	for submit <at> debbugs.gnu.org; Fri, 04 Jan 2019 18:30:49 -0500
Received: from mo4-p00-ob.smtp.rzone.de ([81.169.146.218]:33126)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <bruno@HIDDEN>) id 1gfYvN-0008UQ-Mu
 for 33965 <at> debbugs.gnu.org; Fri, 04 Jan 2019 18:30:47 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1546644644;
 s=strato-dkim-0002; d=clisp.org;
 h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:
 X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender;
 bh=YKY71bg2K+aRo73JF+nqXalqTdfCWKnzxQR2orgt7zw=;
 b=LQvys7U8FFO6Z46IU7+bgokP4hDrXUiFHBq57kkQ/aPMiZuts+tnyYnSpVFw0lzFLn
 lkYTEQHUG0RTjWPHiqR48AMJUrC6f3eq1cNlC//GR1KefkTnuP0g0oSQfBZhV9i1gTUl
 gzN0zsesusSRb6sb17J161G6WPGjVG9DbLw/HPS8K0tfdOnXSmRulLl///C15BH+Jm4j
 pMZ0I1J+HYAWuwT5W+AbCJHjZYP71Pm6rGKNWXkxuBdHXFoFGINlPEhuOcXyun07QIxL
 Kg7hRnkvB5UGP60wNFQdddxsWKCVIhqO5++HAZMujEj+HIq4EfSPLDD2etCG17auTTqo
 HoBw==
X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOGKf2y/s="
X-RZG-CLASS-ID: mo00
Received: from bruno.haible.de by smtp.strato.de (RZmta 44.9 DYNA|AUTH)
 with ESMTPSA id v0a34ev04NUe45p
 (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve secp521r1 with 521 ECDH
 bits, eq. 15360 bits RSA)) (Client did not present a certificate);
 Sat, 5 Jan 2019 00:30:40 +0100 (CET)
From: Bruno Haible <bruno@HIDDEN>
Date: Sat, 05 Jan 2019 00:30:39 +0100
Message-ID: <1742217.p5sQxCVaLy@omega>
User-Agent: KMail/5.1.3 (Linux/4.4.0-141-generic; KDE/5.18.0; x86_64; ; )
In-Reply-To: <5640e0dc-e97f-fc77-0087-9dbc8c506dc5@HIDDEN>
References: <6639990.yRvKeTYcJc@omega>
 <CA+8g5KEe5CDHBKFqUgEUTV6saK2XDSn2_SVPQp_U53SRMABDWA@HIDDEN>
 <5640e0dc-e97f-fc77-0087-9dbc8c506dc5@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="us-ascii"
X-Spam-Score: -0.7 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

Sorry, Paul, but I have to vehemently disagree here. You are mixing
two different questions:
  (A) What is the best behaviour for a kernel?
  (B) What is the best behaviour for a program?

About (A):
> We should encourage platforms like HP-UX that try to work around the 
> trouble

The question is: Is it better for a kernel to be minimalist, hence
exec() does nothing special with the file descriptors? Or is it better
for a kernel to avoid pitfalls for programs, by protecting the first
3 file descriptors?

It is similar to the question: In the case of a signal delivery, should
a read() or write() system call return with a partial result or EINTR, or
should the kernel protect the programs from this knowledge and programming
overhead? This question was extensively discussed under the title
"worse is better", see
https://www.jwz.org/doc/worse-is-better.html
https://en.wikipedia.org/wiki/Worse_is_better

I have no personal opinion on this question.

About (B):
> I'd rather think of this as a bug in the test case, not a bug in 'diff'. 
Here I disagree.

* The majority of the uses of 'diff' and coreutils is through shell scripts.

* <&- and >&- are POSIX-standardized syntaxes in shell scripts for a long
  time.

* It is a goal to make the same shell script work the same way on different
  platforms. The user gains nothing if you tell them "your shell script
  works differently on Linux than on HP-UX because the kernel behaves
  slightly differently".

* Therefore the gnulib modules
    dirent-safer
    fcntl-safer
    fopen-safer
    freopen-safer
    openat-safer
    pipe2-safer
    popen-safer
    stdlib-safer
    tmpfile-safer
    unistd-safer
  serve a good purpose. They make programs running on Linux and
  programs running on HP-UX behave more similarly, which is a good thing.

> This is because the test case assumes more about the shell's "<&-" 
> construct than what POSIX requires.

It is like saying that it would be OK for a program, when interrupted
through Ctrl-Z and restarted through 'fg', to stop processing and exit
with a message "read: Interrupted system call". That's indeed how some
programs behaved around 1992: POSIX allowed the kernel to return from a
read() system call with errno = EINTR. But users don't want this. So it
was seen as a bug in the program, and fixed.

Same here.

Bruno





Message sent to bug-diffutils@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#33965: [bug-diffutils] bug#33965: handling of closed file descriptors
Resent-From: Paul Eggert <eggert@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-diffutils@HIDDEN
Resent-Date: Sat, 05 Jan 2019 00:33:01 +0000
Resent-Message-ID: <handler.33965.B33965.15466483806362 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 33965
X-GNU-PR-Package: diffutils
X-GNU-PR-Keywords: 
To: Bruno Haible <bruno@HIDDEN>
Cc: 33965 <at> debbugs.gnu.org, jim@HIDDEN
Received: via spool by 33965-submit <at> debbugs.gnu.org id=B33965.15466483806362
          (code B ref 33965); Sat, 05 Jan 2019 00:33:01 +0000
Received: (at 33965) by debbugs.gnu.org; 5 Jan 2019 00:33:00 +0000
Received: from localhost ([127.0.0.1]:47131 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gfZtc-0001eY-5j
	for submit <at> debbugs.gnu.org; Fri, 04 Jan 2019 19:33:00 -0500
Received: from zimbra.cs.ucla.edu ([131.179.128.68]:57324)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eggert@HIDDEN>) id 1gfZta-0001eI-Ak
 for 33965 <at> debbugs.gnu.org; Fri, 04 Jan 2019 19:32:59 -0500
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id 1DF0B160F47;
 Fri,  4 Jan 2019 16:32:52 -0800 (PST)
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032)
 with ESMTP id izH4715T2GGL; Fri,  4 Jan 2019 16:32:51 -0800 (PST)
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id 41AD5160F48;
 Fri,  4 Jan 2019 16:32:51 -0800 (PST)
X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id dUPc5aBw-bq7; Fri,  4 Jan 2019 16:32:51 -0800 (PST)
Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200])
 by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 252C9160F46;
 Fri,  4 Jan 2019 16:32:51 -0800 (PST)
References: <6639990.yRvKeTYcJc@omega>
 <CA+8g5KEe5CDHBKFqUgEUTV6saK2XDSn2_SVPQp_U53SRMABDWA@HIDDEN>
 <5640e0dc-e97f-fc77-0087-9dbc8c506dc5@HIDDEN> <1742217.p5sQxCVaLy@omega>
From: Paul Eggert <eggert@HIDDEN>
Openpgp: preference=signencrypt
Autocrypt: addr=eggert@HIDDEN; prefer-encrypt=mutual; keydata=
 xsFNBEyAcmQBEADAAyH2xoTu7ppG5D3a8FMZEon74dCvc4+q1XA2J2tBy2pwaTqfhpxxdGA9
 Jj50UJ3PD4bSUEgN8tLZ0san47l5XTAFLi2456ciSl5m8sKaHlGdt9XmAAtmXqeZVIYX/UFS
 96fDzf4xhEmm/y7LbYEPQdUdxu47xA5KhTYp5bltF3WYDz1Ygd7gx07Auwp7iw7eNvnoDTAl
 KAl8KYDZzbDNCQGEbpY3efZIvPdeI+FWQN4W+kghy+P6au6PrIIhYraeua7XDdb2LS1en3Ss
 mE3QjqfRqI/A2ue8JMwsvXe/WK38Ezs6x74iTaqI3AFH6ilAhDqpMnd/msSESNFt76DiO1ZK
 QMr9amVPknjfPmJISqdhgB1DlEdw34sROf6V8mZw0xfqT6PKE46LcFefzs0kbg4GORf8vjG2
 Sf1tk5eU8MBiyN/bZ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V6swJ9VNCS6pLiEohT3fm7aXm15tZOIyzMZhHRSAPblXxQ0ZSWjq8oRrcYNFx
 c4W1URpAkBCOYJoXvQfD5L3lqAl8TCqDUzYxhH/tJhbDdHrqHH767jaDaTB1+Talp/2AMKwc
 XNOdiklGxbmHVG6YGl6g8Lrbsu9NZEI4yLlHzuikthJWgz+3vZhVGyNlt+HNIoF6CjDL2omu
 5cEq4RDHM44QqPk6l7O0pUvN1mT4B+S1b08RKpqm/ff015E37HNV/piIvJlxGAYz8PSfuGCB
 1thMYqlmgdhd9/BabGFbGGYHA6U4/T5zqU+f6xHy1SsAQZ1MSKlLwekBIT+4/cLRGqCHjnV0
 q5H/T6a7t5mPkbzSrOLSo4puj+IToNjYyYIDBWzhlA19avOa+rvUjmHtD3sFN7cXWtkGoi8b
 uNcby4U=
Organization: UCLA Computer Science Department
Message-ID: <d4d28d01-5433-4d39-a723-c41ae9edb1cb@HIDDEN>
Date: Fri, 4 Jan 2019 16:32:50 -0800
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101
 Thunderbird/60.3.1
MIME-Version: 1.0
In-Reply-To: <1742217.p5sQxCVaLy@omega>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Content-Language: en-US
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

On 1/4/19 3:30 PM, Bruno Haible wrote:
>
>> the test case assumes more about the shell's "<&-"
>> construct than what POSIX requires.
> It is like saying that it would be OK for a program, when interrupted
> through Ctrl-Z and restarted through 'fg', to stop processing and exit
> with a message "read: Interrupted system call".

I don't see the analogy at all. Currently diffutils has a test shell 
script that is not portable POSIX code. Although we've worked around the 
problem with HP-UX by hacking on 'diff' itself, there are plausible 
POSIX platforms where our current hack will not work. It's not 
unreasonable to expect that test scripts should limit themselves to 
POSIX features so that they are as portable as reasonably possible.

> POSIX allowed the kernel to return from a
> read() system call with errno = EINTR. But users don't want this. So it
> was seen as a bug in the program, and fixed.

If by "users" you mean "programs that make system calls", then many 
users *do* want that. Certainly Emacs does, and I imagine many other 
programs do too. If you meant something else by "users" then I'm not 
sure I'm following the analogy.

For the stdin-is-closed situation, the users and developers of many (I 
would say most) applications do not want 'open' to hijack stdin. 
Although the HP-UX solution to this problem may not be best, it's better 
than the traditional behavior as it is a simple change to the kernel 
that fixes the issue for all applications, as opposed to the 
more-complicated dances we do in openat-safer and friends.

After thinking about this a bit more, the message that I'm getting from 
all this is that we should change diffutils to no longer rely on the 
"feature" that stdin is closed, and remove the test cases that attempt 
to test for this "feature". The feature is not portable to POSIX 
platforms. Besides, I doubt whether anybody is using the feature anyway. 
I put the feature in many years ago, so I can take the blame for 
introducing the misguided feature and the responsibility for taking it out.





Message sent to bug-diffutils@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#33965: [bug-diffutils] bug#33965: handling of closed file descriptors
Resent-From: Bruno Haible <bruno@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-diffutils@HIDDEN
Resent-Date: Sat, 05 Jan 2019 09:42:01 +0000
Resent-Message-ID: <handler.33965.B33965.15466812902122 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 33965
X-GNU-PR-Package: diffutils
X-GNU-PR-Keywords: 
To: Paul Eggert <eggert@HIDDEN>
Cc: 33965 <at> debbugs.gnu.org, jim@HIDDEN
Received: via spool by 33965-submit <at> debbugs.gnu.org id=B33965.15466812902122
          (code B ref 33965); Sat, 05 Jan 2019 09:42:01 +0000
Received: (at 33965) by debbugs.gnu.org; 5 Jan 2019 09:41:30 +0000
Received: from localhost ([127.0.0.1]:47241 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gfiSQ-0000YA-0U
	for submit <at> debbugs.gnu.org; Sat, 05 Jan 2019 04:41:30 -0500
Received: from mo4-p00-ob.smtp.rzone.de ([85.215.255.22]:18895)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <bruno@HIDDEN>) id 1gfiSN-0000Xz-6r
 for 33965 <at> debbugs.gnu.org; Sat, 05 Jan 2019 04:41:28 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1546681285;
 s=strato-dkim-0002; d=clisp.org;
 h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:
 X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender;
 bh=yRwiNJEBgxBTEMLPMs3FMTpZgs78C0PCFq/AdqOFj+g=;
 b=UJRp/M1nR5Rkjn5nHM+Dv0B4mbYfZyw932kGM0aRGkNHUYTY2djIFb8wzRq2N/cH+c
 Ey6LffW3AMMBV4m25SKZVQ4NWkQgO+I34hklE/15FtNmTMFlAW7nZFWkjbJ2ZYP/TYhe
 NDjrZQpJ1K6Jov9NBbpmUaZXNW45tK+02PBhzNm5f6NohsUYZwZtu2BKMbu/5tgKjp7T
 DBR5z9NPta0JBKCNR9ysYYx5Egvm8Khhrt+YD/4bKflP55qkOvDmj2HL7rt/P4Gl+iRD
 dEk/ZpHwtb0gTrXDlWIdZMG8TKlt8zWNXFdcTuPvLQgwYP2iFsKmN/hSYblFBzhX6meK
 hkiA==
X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOGKf2y/s="
X-RZG-CLASS-ID: mo00
Received: from bruno.haible.de by smtp.strato.de (RZmta 44.9 DYNA|AUTH)
 with ESMTPSA id v0a34ev059fK5mW
 (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve secp521r1 with 521 ECDH
 bits, eq. 15360 bits RSA)) (Client did not present a certificate);
 Sat, 5 Jan 2019 10:41:20 +0100 (CET)
From: Bruno Haible <bruno@HIDDEN>
Date: Sat, 05 Jan 2019 10:41:20 +0100
Message-ID: <1637429.tjGFVHuugb@omega>
User-Agent: KMail/5.1.3 (Linux/4.4.0-141-generic; KDE/5.18.0; x86_64; ; )
In-Reply-To: <d4d28d01-5433-4d39-a723-c41ae9edb1cb@HIDDEN>
References: <6639990.yRvKeTYcJc@omega> <1742217.p5sQxCVaLy@omega>
 <d4d28d01-5433-4d39-a723-c41ae9edb1cb@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="us-ascii"
X-Spam-Score: -0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

> > It is like saying that it would be OK for a program, when interrupted
> > through Ctrl-Z and restarted through 'fg', to stop processing and exit
> > with a message "read: Interrupted system call". ...
> > POSIX allowed the kernel to return from a
> > read() system call with errno = EINTR. But users don't want this. So it
> > was seen as a bug in the program, and fixed.
> 
> If by "users" you mean "programs that make system calls"

By "users don't want this" I meant: Users don't want programs to terminate
with an error message "read: Interrupted system call", just because they
used the job control features of the shell.

Bruno





Message sent to bug-diffutils@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#33965: handling of closed file descriptors
Resent-From: Bruno Haible <bruno@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-diffutils@HIDDEN
Resent-Date: Sat, 05 Jan 2019 09:45:01 +0000
Resent-Message-ID: <handler.33965.B33965.15466814752405 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 33965
X-GNU-PR-Package: diffutils
X-GNU-PR-Keywords: 
To: Paul Eggert <eggert@HIDDEN>
Cc: 33965 <at> debbugs.gnu.org, bug-gnulib@HIDDEN, jim@HIDDEN
Received: via spool by 33965-submit <at> debbugs.gnu.org id=B33965.15466814752405
          (code B ref 33965); Sat, 05 Jan 2019 09:45:01 +0000
Received: (at 33965) by debbugs.gnu.org; 5 Jan 2019 09:44:35 +0000
Received: from localhost ([127.0.0.1]:47245 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gfiVP-0000ci-EV
	for submit <at> debbugs.gnu.org; Sat, 05 Jan 2019 04:44:35 -0500
Received: from mo4-p01-ob.smtp.rzone.de ([85.215.255.52]:35525)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <bruno@HIDDEN>) id 1gfiVM-0000cW-Qo
 for 33965 <at> debbugs.gnu.org; Sat, 05 Jan 2019 04:44:33 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1546681471;
 s=strato-dkim-0002; d=clisp.org;
 h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:
 X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender;
 bh=BliwxpfNtROna93LCjH0ZPiEMNfrDkGbPhJVfB2NHhI=;
 b=i3PvrxvOlCw/1rX9sEDhFLT/sqfHKoe7wRQq0IY7rVvGLU87YRc+a2gdSSJ7kYIEwg
 zsHDojYaMuNQvzvaECSYF1F8lYdmTguNEb5uUUSV+1nmRDar0YgT5j6zE1o0/uIJjNMA
 /AXCC808N65qDVl399RTyV0Y4R5XtTWw43DbpDXGeyvlpcJ1MdzvvcjfBK+jYllvCU50
 yvI6rwDxfTmJsW4aZB3D/E1fPjqb0OSWRsRul0Km1JQs3aBW3eNnFy65+eIm0gltyL9b
 kjBbntDV4qY0L9FPahqz2LLp7Lxt3eJnV2HZk8dHO5OYWb5sQjEB2cd+q0JzE+mTTAjg
 xWRQ==
X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOGKf2y/s="
X-RZG-CLASS-ID: mo00
Received: from bruno.haible.de by smtp.strato.de (RZmta 44.9 DYNA|AUTH)
 with ESMTPSA id v0a34ev059iI5mv
 (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve secp521r1 with 521 ECDH
 bits, eq. 15360 bits RSA)) (Client did not present a certificate);
 Sat, 5 Jan 2019 10:44:18 +0100 (CET)
From: Bruno Haible <bruno@HIDDEN>
Date: Sat, 05 Jan 2019 10:44:17 +0100
Message-ID: <2095398.ToFATaR5yE@omega>
User-Agent: KMail/5.1.3 (Linux/4.4.0-141-generic; KDE/5.18.0; x86_64; ; )
In-Reply-To: <d4d28d01-5433-4d39-a723-c41ae9edb1cb@HIDDEN>
References: <6639990.yRvKeTYcJc@omega> <1742217.p5sQxCVaLy@omega>
 <d4d28d01-5433-4d39-a723-c41ae9edb1cb@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="us-ascii"
X-Spam-Score: -0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

[CCing bug-gnulib. This is a followup to
 https://debbugs.gnu.org/cgi/bugreport.cgi?bug=33965 ]

Hi Paul,

> The feature is not portable to POSIX 
> platforms. Besides, I doubt whether anybody is using the feature anyway. 

OK, if you question the "feature" as a whole, then I'd say:

* Users don't *need* the "feature", in the sense that:
  - The normal way of invoking a program is by providing arguments
    and standard input/output streams. Users who want to invoke a program
    are not actively looking for this contorted way to invoke a program.
  - For most programs, equivalent functionality to the "feature" is available
    by passing an empty string, a reference to an empty file, or /dev/null
    as argument. If a program exists for which the equivalent functionality
    is not available through the normal way of invocation, the developers
    should better add it.

* But it's a security risk that a program can be invoked in ways in which it
  was surely never tested. Anything can happen then - from overwriting precious
  files of the user to endless loops.

* Therefore if you want to take out the "feature", you still have to think
  about how to mitigate the security risks.

  > Although the HP-UX solution to this problem may not be best, it's better 
  > than the traditional behavior as it is a simple change to the kernel 
  > that fixes the issue for all applications, as opposed to the 
  > more-complicated dances we do in openat-safer and friends.

  Given
    - the prevalent "worse is better" attitude,
    - the "never break userland behaviour that programs may rely upon"
      principle of the Linux kernel community,
    - the fact that the glibc people looked at the problem and used the
      HP-UX solution only for setuid programs,
  I predict that this "simple change to the kernel" will not make it into
  the majority of the operating systems in the next 10 years. (But you
  could start lobbying for it among the OpenBSD people. They would be the
  most likely to adopt it, I guess.)

  In the mean time, the remaining options I can see are:

    (a) Keep using the *-safer Gnulib modules.

    (b) Introduce a sanity_check_file_descriptors() function that all programs
        can invoke right at the beginning of main(), and that exits with an
        exit code if it detects a closed fd.

        void
        sanity_check_file_descriptors (void)
        {
          int fd;
          for (fd = 0; fd <= 2; fd++)
            if (fcntl (fd, F_GETFD, NULL) < 0 && errno == EBADF)
              exit (125);
        }

        On platforms like HP-UX, this code would not cause an exit, but
        the exec() call has already provided substitutes for the closed fds;
        this mitigates the security risks.
        I would propose exit code 125, since 127 and 126 are already taken [1].

  (b) surely is simpler than (a).

Bruno

[1] http://tldp.org/LDP/abs/html/exitcodes.html






Last modified: Sat, 5 Jan 2019 10:00:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.