anchor.diff:    channel)
   
   
  +;;;;;;;;;;;;;;;;;;;;;;;;;;
  +;;; CONTINUOUS READING ;;;
  +;;;;;;;;;;;;;;;;;;;;;;;;;;
  +
  +;;; maintain a background thread that will continuously read the
  +;;; channel
  +
  +(defun make-listener (channel-name &key last)
  +  (let ((lock (sb-thread:make-mutex))
  +        (buffer nil)
  +        (continue t))
  +    (let ((thread  ; start the listening thread
  +           (sb-thread:make-thread
  +            (lambda () (let ((channel (ach-open channel-name
  +                                           :direction :input :last last)))
  +                    (unwind-protect (loop
  +                                       while continue
  +                                       for tmp-buffer = (ach-read channel)
  +                                       do (sb-thread:with-mutex (lock)
  +                                            (setq buffer tmp-buffer)))
  +                      (ach-close channel))))
  +            :name (concatenate 'string "ach-listener-" channel-name))))
  +      ;; return a closure to get the next buffer or terminate the listener
  +      (lambda (&key terminate)
  +        (if terminate
  +            ;; stop the listener
  +            (progn
  +              ;; FIXME: be more robust
  +              (setq continue nil)
  +              (sb-thread:join-thread thread))
  +            ;; get the buffer
  +            (progn
  +              (sb-thread:with-mutex (lock)
  +                (copy-seq buffer))))))))
  +
  +
  
positive.code:     (encode-int *size-delim* :little 0)
      (encode-int (length buffer) :big 4)
      (encode-int *data-delim* :little 8)
      (write-bytes-dammit size-buf s)
      (write-bytes-dammit buffer s)))
  
  
  (defun ach-status (channel)
  
negative.code: (defun channel-output (channel)
    (sb-ext:process-output (channel-process channel)))
  
  (defun ach-open (channel-name &key (direction :input) last)
    "Open an ach channel"
    (let ((proc-input (if (eq direction :output) :stream))
          (proc-output (if (eq direction :input) :stream)))
      (make-channel
       :direction direction
       :process (sb-ext:run-program "achpipe"
                                    `(
                                      ,(case direction
                                             (:input "-s")
                                             (:output "-p")
                                             (otherwise (error "Invalid direction: ~A"
                                                               direction)))
                                       ,channel-name
                                       ,@(when last (list "--last")))
                                    :search t
                                    :wait nil
                                    :input proc-input
  