unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Jacob Hrbek <kreyren@rixotstudio.cz>
To: Maxime Devos <maximedevos@telenet.be>, guile-user@gnu.org
Subject: Re: How to capture pid of (system process?
Date: Fri, 17 Dec 2021 01:32:56 +0000	[thread overview]
Message-ID: <45d70782-ec32-355d-9ecd-44e0dc8de4e8@rixotstudio.cz> (raw)
In-Reply-To: <5f0a15eea9c3b9d111f8e096a3a37571a95e5795.camel@telenet.be>


[-- Attachment #1.1: Type: text/plain, Size: 2084 bytes --]

 > While Guile does not directly provide a function to get the PID of an 
arbitrary process, we could use pgrep to find what we need. -- Tim

I don't want it to depend on an external commands as the implementation 
is not robust enough for my environment (this codeblock doesn't have to 
be robust, but the project is designed for aviation and i want to do 
similar implementations later for more mission critical functions).

So preferably i need a derivation that integrates with the system and is 
OS independent.

 > 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). -- Devos

Can you elaborate? (I am noob in guile atm)

- Jacob Hrbek

On 12/14/21 14:25, Maxime Devos wrote:
> 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
>

[-- Attachment #1.2: publickey - kreyren@rixotstudio.cz - 1677db82.asc --]
[-- Type: application/pgp-keys, Size: 713 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 249 bytes --]

  reply	other threads:[~2021-12-17  1:32 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
2021-12-17  1:32   ` Jacob Hrbek [this message]
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=45d70782-ec32-355d-9ecd-44e0dc8de4e8@rixotstudio.cz \
    --to=kreyren@rixotstudio.cz \
    --cc=guile-user@gnu.org \
    --cc=maximedevos@telenet.be \
    /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).