[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to capture pid of (system process?
From: |
Timothy Sample |
Subject: |
Re: How to capture pid of (system process? |
Date: |
Fri, 17 Dec 2021 11:24:04 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) |
Hi Jacob,
Jacob Hrbek <kreyren@rixotstudio.cz> writes:
>> 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).
>
> Can you elaborate? (I am noob in guile atm)
If you want to dig into it, the GNU manual is not half bad:
https://www.gnu.org/software/libc/manual/html_node/Processes.html
Guile just wraps those same C functions, so that description applies
quite well to Guile. Here’s the Guile reference for the procedures
you’d need:
https://www.gnu.org/software/guile/manual/html_node/Processes.html
Alternatively, if you are feeling adventurous – you must be if you are
using Potato Make :) – you could try and use Gash, too. You would end
up with a very Scheme-y Make experience indeed!
Gash’s interface is laser focused on shell semantics so far, so it’s a
little wonky as a Scheme library, but here’s an example:
(use-modules (gash environment)
(gash shell))
(sh:async
(lambda ()
(execlp "emacs")))
(display "waiting a bit...\n")
(sleep 5)
(let ((emacs-pid (get-last-job)))
(display "sending SIGTERM to ")
(display emacs-pid)
(newline)
(kill emacs-pid SIGTERM))
Gash is very much experimental software when used like this, though.
The latest release does not have ‘sh:async’, so you would have to build
it from Git. It might not be super practical, but it would be fun! :)
-- Tim