>>>>> "Michael" == Michael Sperber [Mr Preprocessor]
>>>>> <sperber@informatik.uni-tuebingen.de> writes:
Michael> The trivial question is whether you're sure that your
Michael> helper program always flushes its output to point where a
Michael> complete S-expression results.
Is this a problem? Wouldn't (read) block anyway until it has read a
complete sexp? The following at least seems to work:
,----
| lunaris:~/sunray/ufr/scsh% cat read2.scm
| #!/usr/local/bin/scsh -s
| !#
|
| (write (read))
| (newline)
|
| (write (read))
| (newline)
|
| lunaris:~/sunray/ufr/scsh% cat write2.c
|
| #include <stdio.h>
|
| int main(void)
| {
| puts("("); fflush(stdout);
| puts("foo"); fflush(stdout);
| puts("."); fflush(stdout);
| fputs("ba", stdout); fflush(stdout);
| puts("r"); fflush(stdout);
| puts(") (Foo ."); fflush(stdout);
| fputs("Ba", stdout); fflush(stdout);
| puts("r"); fflush(stdout);
| puts(")");
|
| return 0;
| }
| lunaris:~/sunray/ufr/scsh% gcc -Wall write2.c -o write2
| lunaris:~/sunray/ufr/scsh% ./write2 | ./read2.scm
| (foo . bar)
| (Foo . Bar)
| lunaris:~/sunray/ufr/scsh%
`----
Flushing within sexps/tokens or omitting flushing between sexps does
not seem to do any harm, and this is what I would have expected. Or do
you mean that scsh fails to (read) sexps properly if the writer
blocks because the pipe's buffer runs full within a sexp? That doesn't
seem to be a problem either, and I don't think it should be:
,----
| lunaris:~/sunray/ufr/scsh% cat read3.scm
| #!/usr/local/bin/scsh \
| -dm -o read3 -e start -s
| !#
|
| (define-structure read3
|
| (export start)
|
| (open scheme scsh threads)
|
| (begin
|
| (define (start args)
| (sleep 5000)
| (write (length (read)))
| (newline))))
| lunaris:~/sunray/ufr/scsh% cat write3.c
|
| #include <stdio.h>
|
| int main(void)
| {
| int i;
|
| fputs("(", stdout);
| for (i = 0; i < 12000; i++)
| fputs("foo ", stdout);
| puts(")");
|
| return 0;
| }
| lunaris:~/sunray/ufr/scsh% gcc -Wall write3.c -o write3
| lunaris:~/sunray/ufr/scsh% ./write3 | ./read3.scm
| 12000
| lunaris:~/sunray/ufr/scsh%
`----
My understanding is that (read) treats its input as a simple stream of
octets without regard to linebreaks (other than treating them as
whitespace) or blocking in OS-level reads; or am I missing something?
Michael> Other than that, your best bet is probably posting as
Michael> much of the code as possible so we can try to reproduce
Michael> the problem.
I'll see what I can do.
Oh yes, the Scsh version is 0.6.3
Regards,
Stefan
--
Stefan Jankowski
University of Freiburg, CS Dpt.
s/spambucket//
s/dave\.null/janky/
|