From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Diogo F. S. Ramos" Newsgroups: gmane.lisp.guile.user Subject: Re: What is the output port of `system*'? Date: Sun, 27 Apr 2014 02:30:18 -0300 Message-ID: <87zjj7fifp.fsf@nebulosa.milkyway> References: <87mwf7hnly.fsf@nebulosa.milkyway> <87siozn2e7.fsf@taylan.uni.cx> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1398576650 18112 80.91.229.3 (27 Apr 2014 05:30:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 27 Apr 2014 05:30:50 +0000 (UTC) Cc: guile-user@gnu.org To: Taylan Ulrich Bayirli/Kammer Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Apr 27 07:30:43 2014 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WeHfm-00061w-Ax for guile-user@m.gmane.org; Sun, 27 Apr 2014 07:30:42 +0200 Original-Received: from localhost ([::1]:38085 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WeHfl-0006QW-RM for guile-user@m.gmane.org; Sun, 27 Apr 2014 01:30:41 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59752) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WeHfY-0006JA-AM for guile-user@gnu.org; Sun, 27 Apr 2014 01:30:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WeHfT-0008I4-0N for guile-user@gnu.org; Sun, 27 Apr 2014 01:30:28 -0400 Original-Received: from mx1.riseup.net ([198.252.153.129]:49194) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WeHfS-0008Ht-Qe for guile-user@gnu.org; Sun, 27 Apr 2014 01:30:22 -0400 Original-Received: from fruiteater.riseup.net (fruiteater-pn.riseup.net [10.0.1.74]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "*.riseup.net", Issuer "Gandi Standard SSL CA" (not verified)) by mx1.riseup.net (Postfix) with ESMTPS id 07FD258512; Sat, 26 Apr 2014 22:30:22 -0700 (PDT) Original-Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dfsr@fruiteater.riseup.net) with ESMTPSA id 32A86EAD User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-Virus-Scanned: clamav-milter 0.98.1 at mx1 X-Virus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 198.252.153.129 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:11231 Archived-At: > "Diogo F. S. Ramos" writes: > >> The following program doesn't output to a string, which I expected. >> >> (define foo >> (with-output-to-string >> (lambda () >> (system* "ls" "/tmp")))) > > As the manual says about `system*': >> The command is executed using fork and execlp. > > That implies certain restrictions. See (ice-9 popen), documented in > (info "(guile) Pipes"). That also spawns a process but sets its stdout > to a Unix pipe for which it gives you a Guile port, from which you can > drain the output to construct a string. Thanks for the pipe reference. Indeed, something can probably be written with these pipes to achieve what my sample program tried to do tho the higher issue remains. > (Details: `with-output-to-string' could be said to work by setting the > current output port to some special value (a "string port" I guess) that > tells the deepest Guile IO procedures to construct a string instead of > writing to a file descriptor; when you spawn a separate process you > obviously lose this ability, the spawned process simply inherits the > current stdout file descriptor of the Guile process and writes to that.) I'm not sure about the underlying implementation, but I expected all output to (current-output-port) going to the resulting string, hence my question. As an example of this behavior, I point to the following Racket program: --8<---------------cut here---------------start------------->8--- #lang racket (define foo (with-output-to-string (lambda () (system* (find-executable-path "ls") "/tmp")))) --8<---------------cut here---------------end--------------->8---