[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-users] Possible stack problem with fork
From: |
Peter Bex |
Subject: |
[Chicken-users] Possible stack problem with fork |
Date: |
Wed, 02 Feb 2005 23:19:36 +0100 |
User-agent: |
Mutt/1.4.2.1i |
Hi all,
I've encountered a really strange bug, and I'm wondering if it's my
own mistake or there's a bug somewhere in chicken.
The code I have is this:
(define (run-and-catch-output program args)
(call-with-values
create-pipe
(lambda (in out)
(let* ([child (lambda ()
(file-close in) ; Close read end
(duplicate-fileno out fileno/stdout) ; out = stdout
(process-execute program args))]
[child-pid (process-fork child)])
(file-close out) ; Close write end
(let ([str (read-string in)]) ; Read out entire file as string
(process-wait child-pid) ; Clean up zombie
str) )) )) ; Return string
This should run a program with the supplied arguments, and then return the
standard output in a string. This seems overly complex maybe, but as
far as I see it's the only way when you want to use a `safe' exec, where
the commandline isn't simply blindly to the shell.
(and hand-parsing the string for special shell characters is evil, IMHO)
After making the above definition, I observed the following:
csi> (display (run-and-catch-output "/bin/ls" '()))
Error: (values) continuation can not receive multiple values: #<procedure>
Error: unbound variable: splay
csi> (display (run-and-catch-output "/bin/ls" '()))
Error: (values) continuation can not receive multiple values: #<procedure>
Error: unbound variable: isplay
Note the second error message. Somehow the string "display" is getting
mangled.
Any ideas?
Regards,
Peter
--
http://www.student.kun.nl/peter.bex
--
"The process of preparing programs for a digital computer
is especially attractive, not only because it can be economically
and scientifically rewarding, but also because it can be an aesthetic
experience much like composing poetry or music."
-- Donald Knuth
pgpoqCkPtq5BC.pgp
Description: PGP signature
- [Chicken-users] Possible stack problem with fork,
Peter Bex <=