[racket] setting environment with subprocess?

7 views
Skip to first unread message

Berthold Baeuml

unread,
Apr 30, 2012, 5:57:54 PM4/30/12
to us...@racket-lang.org
Hi,

when starting a new process from racket (e.g., using subprocess) is there a way to set the environment for the new process, like C-libs execve allows? Maybe, a keyword argument could be added to subprocess?

All the best,
Berthold

--
-----------------------------------------------------------------------
Berthold Baeuml phone: (+49) 8153 282489
DLR/ Institute of Robotics and Mechatronics fax: (+49) 8153 281134
P.O. Box 1116, 82230 Wessling, Germany email: berthol...@dlr.de
http://www.robotic.dlr.de/Berthold.Baeuml


____________________
Racket Users list:
http://lists.racket-lang.org/users

Eli Barzilay

unread,
Apr 30, 2012, 6:06:07 PM4/30/12
to Berthold Baeuml, us...@racket-lang.org
Just now, Berthold Baeuml wrote:
> Hi,
>
> when starting a new process from racket (e.g., using subprocess) is
> there a way to set the environment for the new process, like C-libs
> execve allows? Maybe, a keyword argument could be added to
> subprocess?

A better solution IMO is how Emacs deals with environment variables --
translated to racket, this would be a new parameter, say
`current-subprocess-environment', which you would manipulate as usual,
for example:

(parameterize ([current-subprocess-environment
(cons (cons "FOO" "whatever")
(current-subprocess-environment))])
...anything with subprocesses here...)

And you'd also get the usual tricks, like allowing arbitrary
environment manipulation:

(parameterize ([current-subprocess-environment
(current-subprocess-environment)])
(putenv "FOO" "whatever")
...)

or starting a process in a clean environment to avoid leaking
environment values (a problem that comes up with rudybot):

(parameterize ([current-subprocess-environment '()])
(putenv "FOO" "whatever")
...)

--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://barzilay.org/ Maze is Life!
Reply all
Reply to author
Forward
0 new messages