From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Mathieu Othacehe Newsgroups: gmane.lisp.guile.devel Subject: Re: Subprocess API. Date: Mon, 25 Sep 2017 19:14:22 +0200 Message-ID: <874lrqlmz5.fsf@gmail.com> References: <87a81llos5.fsf@gmail.com> <20170923151937.5bb7d80e@bother.homenet> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1506359677 2188 195.159.176.226 (25 Sep 2017 17:14:37 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 25 Sep 2017 17:14:37 +0000 (UTC) User-Agent: mu4e 0.9.18; emacs 25.2.1 Cc: guile-devel@gnu.org To: Chris Vine Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Sep 25 19:14:31 2017 Return-path: Envelope-to: guile-devel@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 1dwWxf-0008Lw-HA for guile-devel@m.gmane.org; Mon, 25 Sep 2017 19:14:27 +0200 Original-Received: from localhost ([::1]:43518 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwWxm-00043T-It for guile-devel@m.gmane.org; Mon, 25 Sep 2017 13:14:34 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35971) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwWxi-00042S-EJ for guile-devel@gnu.org; Mon, 25 Sep 2017 13:14:31 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dwWxe-0007cA-Ez for guile-devel@gnu.org; Mon, 25 Sep 2017 13:14:30 -0400 Original-Received: from mail-wm0-x235.google.com ([2a00:1450:400c:c09::235]:50124) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dwWxe-0007bX-83 for guile-devel@gnu.org; Mon, 25 Sep 2017 13:14:26 -0400 Original-Received: by mail-wm0-x235.google.com with SMTP id r74so21944612wme.4 for ; Mon, 25 Sep 2017 10:14:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version; bh=H9pjyLOkSSBBj9zp2QcHunGmFt+7aPIphBQOGRe9jc8=; b=DdGzRAtbD0QJGbNLX352hCLorgsNOz1lM6IdDlxZmiNZTWPLbV7ImLIL3rBvSuMH7E dYGE+0Xnyq7oDcxIhQot34LnueTpCB6/Yx2teJLppoFL8sI2wLqenyzEdDOe2KvT9X0d Tya8OceHoFKblWIgKxyMAGZToleTvOz3lRg/N7RvbZRmItK4kL9vF686hmKiRAR1j/87 EV/K2te99bESjHWkkXIcRT2V227DH3/pXMAySvwSSGU+lAmExApqpEvAf0GQrkeRDYcT Yw97tGxNMDysOtBGo5b65A4ik6Tq/HEJZ7BqOVgNTgasPxKOC8ePRGVyTdHUVd2RBrtK f0UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version; bh=H9pjyLOkSSBBj9zp2QcHunGmFt+7aPIphBQOGRe9jc8=; b=U5cSNof6AXn13weU/zVVM7fcDG5KCfYQPOBhGCuSp8Qf/iwdmILt7mAHt7DOk2jr8W Zeb426PHaNB08+qLMZPwqSdna3pichkbzx6Vaq57jHn04tUgfE+uJUesyCEBUyAQLQyq WfRgdkDBuRZSKjWHOL/3qcVvpjADa2KTkbZ5Hkd4EqWjsGMknVRRadXBSJzt9zuhcAOV 5xOfkjAH91pL9b1jMw1XlBdwZHdLl2Ya6w8QvkB/6WXz3eHymPcwgmUhgfcKV05fqRb+ 4z3dK6Aj0aCRHyOrAsW4jRh2XMN2tXJlcCfBuC54T02IgmaZ1kSDLvyiNPHxNONfu2GR bgnw== X-Gm-Message-State: AHPjjUiD5hEVTAhnazL68jULNy+wpFbHiyhmpIOW4Ds5EvL2C4cjsAN7 Ees9kugihhaTQ7eI0DOcw0KxCQ== X-Google-Smtp-Source: AOwi7QCl3mBaOQKvqzuIS5+J8fpDsPkQ2V9P8C5K1wAqlfLBehk+elWsRvA6Dv7tl0y4nfiK6eg88Q== X-Received: by 10.28.63.145 with SMTP id m139mr1045467wma.5.1506359663414; Mon, 25 Sep 2017 10:14:23 -0700 (PDT) Original-Received: from cervin ([78.192.96.126]) by smtp.gmail.com with ESMTPSA id 6sm7907790wru.33.2017.09.25.10.14.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Sep 2017 10:14:22 -0700 (PDT) In-reply-to: <20170923151937.5bb7d80e@bother.homenet> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::235 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.org gmane.lisp.guile.devel:19313 Archived-At: Hi Chris, > This works exactly as you would expect from its POSIX equivalents and > has the advantage that you can read from the pipe as the sub-process is > proceeding rather than just collect at the end. Thank you ! Following your suggestion, I ended-up with : --8<---------------cut here---------------start------------->8--- (let* ((err-pipe (pipe)) (out-pipe (pipe)) (read-out (car out-pipe)) (write-out (cdr out-pipe)) (read-err (car err-pipe)) (write-err (cdr err-pipe)) (pid (run-concurrently+ (apply tail-call-program "...") (write-out 1) (write-err 2))) (ret (status:exit-val (cdr (waitpid pid))))) (close-port write-out) (close-port write-err) (let ((output (read-string read-out)) (error (read-string read-err))) (close-port read-out) (close-port read-err) (case ret ((0) output) (else (raise ...))))) --8<---------------cut here---------------end--------------->8--- which seems to work. However, run-concurrently+ uses "primitive-fork" which is forbiden in a multi-thread context (sadly, mine). Do you have any idea on how to overcome this ? Thanks, Mathieu