X-Loop: help-debbugs@HIDDEN
Subject: bug#24680: Documentation / Behavior of open-pipe* with stderr
Resent-From: Jeff Mickey <j@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-guile@HIDDEN
Resent-Date: Wed, 12 Oct 2016 23:19:02 +0000
Resent-Message-ID: <handler.24680.B.147631432317373 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 24680
X-GNU-PR-Package: guile
X-GNU-PR-Keywords:
To: 24680 <at> debbugs.gnu.org
X-Debbugs-Original-To: bug-guile@HIDDEN
Received: via spool by submit <at> debbugs.gnu.org id=B.147631432317373
(code B ref -1); Wed, 12 Oct 2016 23:19:02 +0000
Received: (at submit) by debbugs.gnu.org; 12 Oct 2016 23:18:43 +0000
Received: from localhost ([127.0.0.1]:53534 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
id 1buSnK-0004W9-Px
for submit <at> debbugs.gnu.org; Wed, 12 Oct 2016 19:18:42 -0400
Received: from eggs.gnu.org ([208.118.235.92]:45042)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <j@HIDDEN>) id 1buSnJ-0004Vt-57
for submit <at> debbugs.gnu.org; Wed, 12 Oct 2016 19:18:41 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
(envelope-from <j@HIDDEN>) id 1buSnC-00023I-FC
for submit <at> debbugs.gnu.org; Wed, 12 Oct 2016 19:18:35 -0400
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,T_DKIM_INVALID
autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:44087)
by eggs.gnu.org with esmtp (Exim 4.71)
(envelope-from <j@HIDDEN>) id 1buSnC-00022t-9O
for submit <at> debbugs.gnu.org; Wed, 12 Oct 2016 19:18:34 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:36005)
by lists.gnu.org with esmtp (Exim 4.71)
(envelope-from <j@HIDDEN>) id 1buSn9-0007kl-N0
for bug-guile@HIDDEN; Wed, 12 Oct 2016 19:18:32 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
(envelope-from <j@HIDDEN>) id 1buSn5-00020x-Cw
for bug-guile@HIDDEN; Wed, 12 Oct 2016 19:18:30 -0400
Received: from out5-smtp.messagingengine.com ([66.111.4.29]:57465)
by eggs.gnu.org with esmtp (Exim 4.71)
(envelope-from <j@HIDDEN>) id 1buSn3-0001x6-WC
for bug-guile@HIDDEN; Wed, 12 Oct 2016 19:18:27 -0400
Received: from compute2.internal (compute2.nyi.internal [10.202.2.42])
by mailout.nyi.internal (Postfix) with ESMTP id 34BE820516;
Wed, 12 Oct 2016 19:18:15 -0400 (EDT)
Received: from frontend1 ([10.202.2.160])
by compute2.internal (MEProxy); Wed, 12 Oct 2016 19:18:15 -0400
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=codemac.net; h=
content-transfer-encoding:content-type:date:from:message-id
:mime-version:subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=Epj
HCfGpJ//6vymXgvwt3lEt+a0=; b=lfapFJCQkz3y+kPfr2tACoAzafkz+AvA/bJ
2ce9fuknUu3Xi7kAOzEzZFlgnd3pI0PapQp1URXe75u7nJPeT/xnkp5xGfiXKQ12
Sp6xMqzyUBLxqDmjSTyN6/4qxqo1sLhcjyhQa0yVsxh2mF5HpXfXqoc0LwQerBXf
nAl/HfuU=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=
messagingengine.com; h=content-transfer-encoding:content-type
:date:from:message-id:mime-version:subject:to:x-sasl-enc
:x-sasl-enc; s=smtpout; bh=EpjHCfGpJ//6vymXgvwt3lEt+a0=; b=EaZ33
awF1zgAELXpJG2pnv+rlqFo0tMyW+wVMDzu00vvFKsDAAE5EEy10ZzGPzsPTotLL
TL70pO9YZYzy5XyVV3j+dPgCFJLwXilLd2z4dR/aK9r2HXYzqKhuFCqQPEtrFjUw
nbjsgy3rdAkotle5ZVbqZc4ruJ+6VDv+hd3WOY=
X-Sasl-enc: vhdmqlqgDxIiv9X7xp198mYqKHYh+WBa1++NEHrQ4lCz 1476314294
Received: from novaria.codemac.net (unknown [64.84.70.252])
by mail.messagingengine.com (Postfix) with ESMTPA id B5F02F2985
for <bug-guile@HIDDEN>; Wed, 12 Oct 2016 19:18:14 -0400 (EDT)
From: Jeff Mickey <j@HIDDEN>
Date: Wed, 12 Oct 2016 16:18:13 -0700
Message-ID: <87fuo12m2y.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
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: -5.0 (-----)
Hi!
So, I like to build up programs by tieing together a few different
programs, and then replacing parts where I reimplement features in
simpler ways.
Currently, I have a piece of guile code that calls out to dd, and I
wanted to capture the stderr and print it if dd failed to run
successfully. If it ran successfully, I just wanted to swallow it.
I read the following from the guile Info page 7.2.10 Pipes under the
procedure documentation for open-pipe*:
For an input pipe, the child=E2=80=99s standard output is the pipe and
standard input is inherited from =E2=80=98current-input-port=E2=80=99. F=
or an
output pipe, the child=E2=80=99s standard input is the pipe and standard
output is inherited from =E2=80=98current-output-port=E2=80=99. In all c=
ases cases
the child=E2=80=99s standard error is inherited from =E2=80=98current-err=
or-port=E2=80=99
(*note Default Ports::).
So, in my assumption, I should be able to use parameterize on
current-error-port, and set it to a string port. Here is some test code:
(use-modules (ice-9 popen))
=20=20
(define (port-copy dst src)
(let ((c (read-char src)))
(if (eof-object? c)
dst
(begin (write-char c dst)
(port-copy dst src)))))
=20=20
(define (print-outs one two)
(format #t "what was stored in stdout:~%~a~%<eond of os>~%" (get-output=
-string os))
(format #t "what was stored in stderr:~%~a~%<eond of es>~%" (get-output=
-string es)))
=20=20
(let ((os (open-output-string))
(es (open-output-string)))
(parameterize ((current-error-port es))
(let ((rp (open-pipe* OPEN_BOTH "logger" "-s" "help me i'm stderr")))
(port-copy os rp)
(status:exit-val (close-pipe rp))))
(print-outs os es))
=20=20
(let ((os (open-output-string))
(es (open-output-string)))
(parameterize ((current-error-port es))
(let ((rp (open-pipe* OPEN_BOTH "echo" "help me i'm stdout")))
(port-copy os rp)
(status:exit-val (close-pipe rp))))
(print-outs os es))
This, notably, is unable to print stderr. I tried changing the
parameterize to a call to set-current-error-port, but this didn't work
either, same results where it's blank.
So, clearly, something is wrong.
Then I looked at the source of posix.c & strports.c & fports.h, and it
looks like string ports cannot be used for open-pipe*. 6.14.8 Default
Ports for Input, Output and Errors do not call this out.
I haven't figured out how to fix it yet, but I think it'd be great if
string/byte ports could be used everywhere, including for
stdout/stdin. Seems like we could check if the in/out/error ports are
fd's or not like currently (line 1388 of posix.c) but in the else
case set up some type of thread (or forked process) that goes off and
copies whatever comes out of the fd into a byte or string port.
I don't know enough about the guile C implementation to make more
concrete suggestions.
Thanks in advance. At the least, I feel like the documentation for
open-pipe* and the Default Ports could be improved significantly.
// codemac
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: Jeff Mickey <j@HIDDEN> Subject: bug#24680: Acknowledgement (Documentation / Behavior of open-pipe* with stderr) Message-ID: <handler.24680.B.147631432317373.ack <at> debbugs.gnu.org> References: <87fuo12m2y.fsf@HIDDEN> X-Gnu-PR-Message: ack 24680 X-Gnu-PR-Package: guile Reply-To: 24680 <at> debbugs.gnu.org Date: Wed, 12 Oct 2016 23:19:02 +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-guile@HIDDEN If you wish to submit further information on this problem, please send it to 24680 <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 24680: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D24680 GNU Bug Tracking System Contact help-debbugs@HIDDEN with problems
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.