scsh-users
[Top] [All Lists]

Re: help strange thread

To: ZHAO Wei <zhaoway@public1.ptt.js.cn>
Subject: Re: help strange thread
From: ZHAO Wei <zhaoway@public1.ptt.js.cn>
Date: Sun, 02 Nov 2003 04:48:28 +0800
Cc: scsh@zurich.csail.mit.edu
ZHAO Wei wrote:
-----------------------------------------
#! /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) (work))))


(define (trouble)
  (display-line "enter troubled work")

To be more specific, the script appears to hang right between these lines.

zw

  (run (begin (display-line "This won't appear the second time")))
  (run (| (begin (display-line "XXX"))
          (nc localhost 8888))))


(define (main ignore)
  (delay-work trouble)
  (let ((watcher (lambda ()
                   (awk (read-line) (line) ()
                        ((: bos "XXX") (delay-work trouble))))))
    (let lp ()
      (run (| (nc -l -p 8888)
              (begin (watcher))))
      (lp))))
----------------------------------

--
zhaoway@public1.ptt.js.cn
http://c2.com/cgi/wiki?ZhaoWay
http://advogato.org/person/zhaoway/
linux.ext2fs.tcp.ip.netfilter.gnu.debian.dpkg.rpm.bash.lex
yacc.gcc.lisp.scheme.ocaml.latex.html.css.php.apache.mysql


<Prev in Thread] Current Thread [Next in Thread>