unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Maxime Devos <maximedevos@telenet.be>
To: Jacob Hrbek <kreyren@rixotstudio.cz>, guile-user@gnu.org
Subject: Re: How to capture pid of (system process?
Date: Tue, 14 Dec 2021 13:25:51 +0000	[thread overview]
Message-ID: <5f0a15eea9c3b9d111f8e096a3a37571a95e5795.camel@telenet.be> (raw)
In-Reply-To: <25238084-6589-146f-566c-89f7df9afad9@rixotstudio.cz>

Jacob Hrbek schreef op ma 13-12-2021 om 21:01 [+0000]:
> I wrote this potato-make <https://github.com/spk121/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




  parent reply	other threads:[~2021-12-14 13:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-13 21:01 How to capture pid of (system process? Jacob Hrbek
2021-12-14 13:05 ` Tim Van den Langenbergh
2021-12-14 13:25 ` Maxime Devos [this message]
2021-12-17  1:32   ` Jacob Hrbek
2021-12-17  6:45     ` Maxime Devos
2021-12-17 16:24     ` Timothy Sample

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5f0a15eea9c3b9d111f8e096a3a37571a95e5795.camel@telenet.be \
    --to=maximedevos@telenet.be \
    --cc=guile-user@gnu.org \
    --cc=kreyren@rixotstudio.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).