From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Maxime Devos Newsgroups: gmane.lisp.guile.user Subject: Re: How to capture pid of (system process? Date: Tue, 14 Dec 2021 13:25:51 +0000 Message-ID: <5f0a15eea9c3b9d111f8e096a3a37571a95e5795.camel@telenet.be> References: <25238084-6589-146f-566c-89f7df9afad9@rixotstudio.cz> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7160"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.38.3-1 To: Jacob Hrbek , guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Tue Dec 14 14:32:36 2021 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mx7v2-0001jw-7f for guile-user@m.gmane-mx.org; Tue, 14 Dec 2021 14:32:36 +0100 Original-Received: from localhost ([::1]:56706 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mx7v0-0000ot-MS for guile-user@m.gmane-mx.org; Tue, 14 Dec 2021 08:32:34 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:52176) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mx7or-0003fO-EO for guile-user@gnu.org; Tue, 14 Dec 2021 08:26:13 -0500 Original-Received: from newton.telenet-ops.be ([195.130.132.45]:59658) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mx7oo-0002kw-Qd for guile-user@gnu.org; Tue, 14 Dec 2021 08:26:13 -0500 Original-Received: from xavier.telenet-ops.be (xavier.telenet-ops.be [IPv6:2a02:1800:120:4::f00:14]) by newton.telenet-ops.be (Postfix) with ESMTPS id 4JCzfK6DgfzMqt3Z for ; Tue, 14 Dec 2021 14:26:01 +0100 (CET) Original-Received: from ptr-bvsjgyhxw7psv60dyze.18120a2.ip6.access.telenet.be ([IPv6:2a02:1811:8c09:9d00:3c5f:2eff:feb0:ba5a]) by xavier.telenet-ops.be with bizsmtp id WDRr2600F4UW6Th01DRroe; Tue, 14 Dec 2021 14:25:51 +0100 In-Reply-To: <25238084-6589-146f-566c-89f7df9afad9@rixotstudio.cz> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r21; t=1639488351; bh=4JIoa+DxSkAZz3ZGv05PhMUBMD7njTCmyIJN1gQQm6c=; h=Subject:From:To:Date:In-Reply-To:References; b=K33ZD5zwKh19q+z0Eo2LxdiWFk3he/ziweYEAFwCLj98QlTSGu6JJDiGXw7KANrut cU6N9mpbrFuyybkMBdck9JJ8t2ZT7imoZT0t32MD6oJ26txeK5ZiEpb591q/xbiYVz i5wnEFK04dB44kL6UzW/WjUNtAktrTW3r7sDR6F6IPZ+dWOh2kzTsOc6J57J/lXZJu 04rnbH+jwexRmFDqjd2eT3E8pXxCaA+l6BUXk4ixENPiqGy3SqRfxlnB00ErlhIdPb P2dF3wTkYb5KIMK1Zj5gnTkR6IdSugXFwwPmpSX7B29Gst8qpHvROTuaC0AEM0rZZ4 tBq159N25GHew== Received-SPF: pass client-ip=195.130.132.45; envelope-from=maximedevos@telenet.be; helo=newton.telenet-ops.be X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:17849 Archived-At: Jacob Hrbek schreef op ma 13-12-2021 om 21:01 [+0000]: > I wrote this potato-make > definition (was simplified): > > #:SRC_BEGIN sheme-mode > #!/usr/bin/env sh > exec guile -s "$0" "$@" > !# > > (use-modules (ice-9 futures) >   (potato make)) > (initialize) > > (: "watch" '() >     (~ (do ((i 1 (1+ i))) >        ((> i 6)) >      (future (system >       "emacs")) >      ;;(let ((emacs_pid (getpid))) >       ;; (kill emacs_pid SIGTERM))))) > > (execute) > #:SRC_END > > expecting to capture emacs's pid and kill it, but the issue is that > using `getpid` gets me the PID of potato-make and `getppid` of the > shell > -> How can i capture just the emacs's pid? 'system' executes the command and waits for it to complete. After it completed, the process is dead so the pid it used to have is useless. If you want to do things asynchronuously, you can look at open-pipe. It should also be possible to build anything you want with the lower- level fork, execl, dup->fdes, ... primitives (assuming things are single-threaded). Greetings, Maxime