I find my problem still somewhere else. :(
Following one screenful snippet demonstrates the weird behavior.
To run it, you should have netcat installed and available as shell
command "nc" which is the case in Debian GNU/Linux.
The below script has race conditions between client and server, but the
original version does not have this race condition, because the server
is always up. To demonstrate my trouble concisely, I have to use nc with
which I don't know how not to introduce the race condition. But anyway,
the race should be largely remedied by the sleep.
Expected output is the repeated display on the console (among other
debug strings) the message "This won't appear the second time". But the
actual result I got, of course, is that the mentioned message only be
shown once. And the script hang before that clause, or during, about
which I'm not sure.
The s48 debugger does not help much, since it looks like the debugger
falls deep within the VM itself. And I don't know enough about the VM to
get anything out of it. :(
Please help me! Thanks!
BTW, I'm writing an magazine article for some interesting and easy
things one can do with SCSH. But obviously I been hitten hard now. Two
days on this problem and I'm still not out. :]
#! /usr/bin/scsh \
-o threads -e main -s
(define (display-line string)
(display string) (newline))
(define (delay-work work)
(spawn (lambda ()
(display-line "will do work after 3 seconds") (sleep 3000)
(display-line "enter troubled work")
(run (begin (display-line "This won't appear the second time")))
(run (| (begin (display-line "XXX"))
(nc localhost 8888))))
(define (main ignore)
(let ((watcher (lambda ()
(awk (read-line) (line) ()
((: bos "XXX") (delay-work trouble))))))
(let lp ()
(run (| (nc -l -p 8888)
Thanks for reading! :)