Changeset 11516

Dec 14, 2008, 7:48:45 AM (11 years ago)

Try to fix the bug addressed by r11513 in a different way, and fix it
on Windows, too. (Whether or not the bug occurred likely had something
to do with whether the process terminated before we noticed EOF on an
fd that was associated with a stream that another monitored fd was
also associated with.) Build the alist once, invalidate an entry
when the associated fd gets EOF/error (by setting the CAR of the pair
to NIL), delete invalid entries if any were invalidated on the previous

1 edited


  • trunk/source/level-1/linux-files.lisp

    r11513 r11516  
    11551155          (loop
    11561156            (when changed
    1157               (setq pairs (pairlis in-fds out-streams)
     1157              (setq pairs (delete nil pairs :key #'car)
    11581158                    changed nil))
    11591159            (when (and terminated (null pairs))
    11831183                              (decf (car token))
    11841184                              (fd-close in-fd)
    1185                               ;; Delete, watching out for the same out-stream being used
    1186                               ;; for different fds
    1187                               (loop for fds on in-fds as streams on out-streams
    1188                                     do (when (eq (car fds) in-fd)
    1189                                          (setf (car fds) :delete (car streams) :delete)))
    1190                               (setq in-fds (delete :delete in-fds)
    1191                                     out-streams (delete :delete out-streams)
    1192                                     changed t))
     1185                              (setf (car p) nil changed t))
    11931186                            (let* ((string (make-string 1024)))
    11941187                              (declare (dynamic-extent string))
    17411734  ;;; So, this tries to loop until the process handle is signaled and
    17421735  ;;; all data has been read.
    1743   (defun monitor-external-process (p)
     1736 (defun monitor-external-process (p)
    17441737    (let* ((in-fds (external-process-watched-fds p))
    17451738           (out-streams (external-process-watched-streams p))
    17511744      (loop
    17521745        (when changed
    1753           (setq pairs (pairlis in-fds out-streams)
     1746          (setq pairs (delete nil pairs :key #'car)
    17541747                changed nil))
    17551748        (when (and terminated (null pairs))
    17831776                         (decf (car token))
    17841777                         (fd-close in-fd)
    1785                          (setq in-fds (delete in-fd in-fds)
    1786                                out-streams (delete out-stream out-streams)
    1787                                changed t)))
     1778                         (setf (car p) nil changed t)))
    17891780                      (let* ((string (make-string 1024)))
Note: See TracChangeset for help on using the changeset viewer.