[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ANN] a lot

From: tantalum
Subject: Re: [ANN] a lot
Date: Mon, 21 Jul 2014 19:14:41 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0

> 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

"process-create" creates a new parallel process
(define pid
    (lambda ()
      ;this will be executed in a completely cloned new process in the
      (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.
(define myrec (make-record-layout (quote (pid env))))
(define-record-accessors myrec (myrec-pid (quote pid)) (myrec-env (quote
(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)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]