From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Chris Vine Newsgroups: gmane.lisp.guile.user Subject: Re: Using open-input-output-pipe Date: Mon, 22 Jan 2018 11:00:35 +0000 Message-ID: <20180122110035.051e073d@dell.homenet> References: <960991a1-9b9c-62c7-e5ce-c16d1cb98dca@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1516618770 6236 195.159.176.226 (22 Jan 2018 10:59:30 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 22 Jan 2018 10:59:30 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Jan 22 11:59:26 2018 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1edZom-0000WK-Rn for guile-user@m.gmane.org; Mon, 22 Jan 2018 11:59:12 +0100 Original-Received: from localhost ([::1]:34990 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1edZqn-00023L-5W for guile-user@m.gmane.org; Mon, 22 Jan 2018 06:01:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58805) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1edZqH-00022d-La for guile-user@gnu.org; Mon, 22 Jan 2018 06:00:50 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1edZqB-0004K5-Vm for guile-user@gnu.org; Mon, 22 Jan 2018 06:00:45 -0500 Original-Received: from mail-wm0-x236.google.com ([2a00:1450:400c:c09::236]:36282) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1edZqB-0004Jb-OX for guile-user@gnu.org; Mon, 22 Jan 2018 06:00:39 -0500 Original-Received: by mail-wm0-x236.google.com with SMTP id f3so15952894wmc.1 for ; Mon, 22 Jan 2018 03:00:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=LoMxVvBP7sYtsMFYOKUiXO5cOyXiNqtfzqkY+2WERaw=; b=ag84OY9MMxoa7fMHh2OOhEgEmsXBBqpjGMCNNvZW8ik3KHANf7+B58XDwaQJz4y39/ 4x1XVN1OR4dS/MxVu4VlqgIwsWmqPKFE9QZsUEYgn7dPVcM1eUFLoNXenWUAdv2yJB4w 5lKF9FKIJnYW8BFv66wKJ5tdtysPDuNMu8VznCOZNnNHiWNG6OiJvy5/B/xMG3dciJKi 87ep7daBlhTjCDmooH6BU9zBRXy5imOYrkI7IK76W1oswTZMZSFA1WK/kughKbGJhbeg M5zwZrl5GwLMb++qMvKKeWek1mor41RZ5YEydBKQHTIraZwbqmLq/2NoB9WSdFNfDC7o LiTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LoMxVvBP7sYtsMFYOKUiXO5cOyXiNqtfzqkY+2WERaw=; b=jfW8SGuinxmKh63b7jAKu0ZBwoV045kcEU3djnEs/0y8eTt0zsirTUCLm3BRximRsC ello8zJTdn4mwwwqW4te4TJDo8zINSDCdRJpM70DACKM4O/vMc3kircOVWKQE7Oiu6iB 0ZrSpw4H9NeWdCJU74JGnjMsOxVqKRdjF785DdHQBEAr0SMXLTLwp396JarydP9tUZ7i kFz19+me4zCwTlBz/37idZiTrq5P9vysEtnfrkrCIzxb4bBiujbrfNIi5XHfDMjjwSEj Robnc15ER01GKaFMq+bBA5iboj9A6sufaC2JrRr+ObfZo64q9JDkH0xgwzJ482vYFe+7 rmiQ== X-Gm-Message-State: AKwxyteGgctBige7+FXE7ws9AXQM0Jp2H6uSM4sBDoveqfqRdyz6mVyx 2IodJMek5ME+Tg0TAtGI5J6nPZMK X-Google-Smtp-Source: AH8x2248K4kK28v8k4FPELrvlV1Vq16WgKOkQNFvWLMPWQb8imrdmh19CzYtL/71ifGMmwjgaQ8hyA== X-Received: by 10.28.198.12 with SMTP id w12mr4687176wmf.75.1516618838064; Mon, 22 Jan 2018 03:00:38 -0800 (PST) Original-Received: from dell.homenet (233.43.112.87.dyn.plus.net. [87.112.43.233]) by smtp.gmail.com with ESMTPSA id l9sm16542321wrb.91.2018.01.22.03.00.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Jan 2018 03:00:36 -0800 (PST) Original-Received: from dell.homenet (localhost [127.0.0.1]) by dell.homenet (Postfix) with ESMTP id 3041E4281E4 for ; Mon, 22 Jan 2018 11:00:35 +0000 (GMT) In-Reply-To: <960991a1-9b9c-62c7-e5ce-c16d1cb98dca@gmail.com> X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.32; x86_64-unknown-linux-gnu) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::236 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.lisp.guile.user:14441 Archived-At: > On 01/21/2018 12:31 PM, Edwin Watkeys wrote: > > > Hi all, > > > > I'm trying to write a procedure that processes some input through a > > unix utility. Open-input-output-pipe returns a bidirectional pipe > > that I can both read and write to. However, there is no way that I > > can figure out to tell the external process that input is complete, > > as there is no way to determine the output port of the rw-port and > > therefore no way to close it. Closing an rw-port closes both the > > read and write ports. > > > > Open-input-output-port therefore seems useful for line-based > > external processes but not for ones that function on the entirety > > of user input e.g. wc and sort. > > > > Is my analysis of the situation roughly accurate? > > > > Regards, > > Edwin If you want fine-grained control, you might want to look at some of the procedures in guile-lib's (os process) module, and in particular the 'run-with-pipe' procedure, or using its 'run-concurrently+' procedure with guile's 'pipe' (the parent can block on its read pipe once it has completed writing to the child until the child process closes the other end of the pipe upon finishing, causing the parent to get an eof-object provided it has itself previously closed the write end of its read pipe). Otherwise if you want to stick to guile proper, you may have to do it by hand. As 'pipe' gives you an input and output port for each pipe which can be independently closed, you could use two of these with the 'dup2', 'fork' and 'execl' procedures. It's tedious though. Chris