ZHAO Wei <zhaoway@public1.ptt.js.cn> writes:
The following script. I can't understand the output which is only two
"yes" without "haha". I think there should be a "haha" in the
output. Please help me clarify! Thank you!
#! /usr/bin/scsh \
-o threads -e main -s
!#
(define (main ignore)
(let* ((headache (lambda ()
(spawn (lambda ()
(run (begin (display "haha") (newline)))))))
(watcher (lambda ()
(awk (read-line) (line) ()
(#t (display line) (newline)
(headache)
(display line) (newline))))))
(run (| (echo "yes") (begin (watcher))))
(sleep (* 3600 1000))))
I believe there is a SCSH bug, but I'm not sure. A work around is to
add a (sleep 1) immediately after the spawn.
Change this:
(spawn (lambda ()
(run (begin (display "haha") (newline)))))))
to:
(spawn (lambda ()
(run (begin (display "haha") (newline)))))
(sleep 1)))
Does this work around fix it for you?