unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: tantalum <sph@posteo.eu>
To: maxim.suraev@campus.tu-berlin.de, guile-user@gnu.org
Subject: Re: [ANN] a lot
Date: Mon, 21 Jul 2014 19:14:41 +0200	[thread overview]
Message-ID: <53CD4A81.4090108@posteo.eu> (raw)

> Are there some code examples?
except for process-chain-* probably not, but i put that on my todo list.

something like this should work:
  (execute-with-environment "XX2=LOL" "/tmp/mybin")

working example:
  guile -c '(import (sph process)) (execute-with-environment (list
"XX2=LOL") "/usr/bin/echo" "test")'

but this is using the system call "execve", which leads to the whole
guile process being replaced by the specified program. (execve syscall
reference: http://man7.org/linux/man-pages/man2/execve.2.html)

"process-create" creates a new parallel process
---
(define pid
  (process-create
    (lambda ()
      ;this will be executed in a completely cloned new process in the
background
      (execute-with-environment "XX2=LOL" "/tmp/mybin"))))

;now, still in the guile process, send a signal to the new process
(kill pid SIGINT)
---
now what happens is that a new process is created by cloning, and is
then immediately replaced by your program. as far as i know this is the
only way on linux or similar systems to archieve this.

for storing values in a record it would probably be best to use a record
setter procedure. the library supports setting fields by symbolic name,
but that is slower.
in general, as a sidenote, a record like this differs from an
association list for example, in that the keys are not stored inside the
data-structure, but separately: the "layout" stores the field names and
the positions of where the field values are stored in the records.
example:
---
(define myrec (make-record-layout (quote (pid env))))
(define-record-accessors myrec (myrec-pid (quote pid)) (myrec-env (quote
env)))
(define-record-setters myrec (myrec-pid-set! (quote pid))
(myrec-env-set! (quote env)))

;two different ways to create a record
(define a (record myrec pid "LOL"))
(define b (make-record myrec))

(myrec-pid a)
(myrec-pid-set! a 3)
(myrec-env-set! b 2)
---

EOM



             reply	other threads:[~2014-07-21 17:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-21 17:14 tantalum [this message]
2014-07-21 22:15 ` [ANN] a lot Max
  -- strict thread matches above, loose matches on Subject: below --
2014-06-23 19:32 tantalum
2014-06-24  0:38 ` David Thompson
2014-06-24  8:50 ` Max

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=53CD4A81.4090108@posteo.eu \
    --to=sph@posteo.eu \
    --cc=guile-user@gnu.org \
    --cc=maxim.suraev@campus.tu-berlin.de \
    /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).