Discussion:
[Larceny-users] process broken?
Ken Dickey
2008-06-21 22:21:26 UTC
Permalink
Greetings,

I am trying to use the 'process proc in "lib/Standard/unix.scm".

Can someone help me out?

Thanks much,
-KenD
=======================================
larceny
Larceny v0.961 "Fluoridation" (Mar 16 2008 14:59:46, precise:Linux:unified)
larceny.heap, built on Sun Mar 16 15:01:38 PDT 2008
(require "Standard/unix")
(require "Standard/unix")
#t
(define p (process "echo"))
p
(#<INPUT PORT input descriptor port 12>
#<OUTPUT PORT output descriptor port 11>
6898)
(display "hello" (cadr p))
Error: write-char: not an output port #<OUTPUT PORT output descriptor port 11>
Entering debugger; type "?" for help.
debug>
;; Huh??
William D Clinger
2008-06-22 01:01:35 UTC
Permalink
Post by Ken Dickey
I am trying to use the 'process proc in "lib/Standard/unix.scm".
Can someone help me out?
Your immediate problem is that the two ports created
by process are binary ports, not textual ports. (The
error message for write-char should have said its
argument was not a textual output port. I changed
that error message just now in response to your bug
report.)

Using binary i/o, however, I encounter yet another
problem: a broken pipe when I attempt to flush or to
close the output port. I don't see anything obviously
wrong with the code, so I'm going to ask Felix about
this.

Will
Felix Klock
2008-06-23 17:23:32 UTC
Permalink
Will (cc'ing Ken and larceny-users)-
Post by William D Clinger
Post by Ken Dickey
I am trying to use the 'process proc in "lib/Standard/unix.scm".
Can someone help me out?
Your immediate problem is that the two ports created
by process are binary ports, not textual ports. (The
error message for write-char should have said its
argument was not a textual output port. I changed
that error message just now in response to your bug
report.)
Using binary i/o, however, I encounter yet another
problem: a broken pipe when I attempt to flush or to
close the output port. I don't see anything obviously
wrong with the code, so I'm going to ask Felix about
this.
The broken pipe does seem undesirable, since it kills the Larceny
process itself.

(FYI, I only see the broken pipe when flushing the output to the echo
process on Solaris, not on Linux or Mac OS X, and also not when
flushing the output to some other processes, such as cat. So one
thing to check is whether the echo program on Solaris has subtle
differences in its behavior from the one on Linux or Mac OS X.)

Ken: what was the goal of your original experiments with process? I
do not think the result of evaluating (process "echo") is terribly
interesting to interact with. I would have thought (process "cat")
would be a more interesting process to interact with (or at least pass
some arguments to echo so that you can see output from it).

Just to put us all on the same page, here are the experiments I used:

% /proj/will/pnkfelix/larcenytest/larceny-native-Nightly-2008-06-23/
larceny_src/larceny
Larceny v0.961 "Fluoridation" (Jun 23 2008 04:24:45,
precise:SunOS5:split)
Post by William D Clinger
(require "Standard/unix")
#t
Post by William D Clinger
(define (test cmd input-string output-n flush?) (let* ((t (native-
transcoder)) (p (process cmd)) (op (cadr p)) (ip (car p))) (put-
bytevector op (string->bytevector input-string t)) (if flush? (flush-
output-port op)) (bytevector->string (get-bytevector-n ip output-n) t)))
Post by William D Clinger
(test "cat" "Input to cat" 10 #t)
"Input to c"
Post by William D Clinger
(test "cat" "Input to cat" 10 #f) ;; waited a while and then hit
Ctrl-C
Keyboard interrupt.
Entering debugger; type "?" for help.
debug> q
Post by William D Clinger
(test "echo Arg of echo" "Input to echo" 10 #f)
"Arg of ech"
Post by William D Clinger
(test "echo Arg of echo" "Input to echo" 10 #t)
Broken Pipe
%



By the way, there was *one* instance where I entered the same text as
above and did not get a Broken Pipe, so the broken pipe may be
resulting from underlying nondeterministic behavior. But almost all
of the times I did the above steps, I would get a broken pipe, so the
problem seems to be reasonable to reproduce...

-Felix

Loading...