Welcome to the CHICKEN Scheme pasting service

read-line blocking on Atom added by kiatoa on Sun Feb 17 14:45:54 2013

(use posix)

(define (conservative-read port)
  (let loop ((res '()))
    (if (not (eof-object? (peek-char port)))
	(loop (cons (read-char port) res))
	(apply conc (reverse res)))))

(define (cmd-run-with-stderr->list cmd . params)
   (let-values (((fh fho pid fhe) (if (null? params)
				      (process* cmd)
				      (process* cmd params))))
       (let loop ((curr (read-line fh))
		  (result  '()))
         (print "GOT HERE 1, curr=" curr)
	 (let ((errstr (conservative-read fhe)))
           (print "GOT HERE 3, errstr=" errstr)
	   (if (not (string=? errstr ""))
	       (set! result (cons errstr result))))
         (print "GOT HERE 2, result=" result)
	 (if (not (eof-object? curr))
	     (begin
	       (print "GOT HERE 4")
	       (loop (read-line fh)
		     (cons curr result)))
	     (begin
	       (print "GOT HERE 5")
	       (close-input-port fh)
	       (close-input-port fhe)
	       (close-output-port fho)
	       (reverse result))))))

(print "Got: " (cmd-run-with-stderr->list "ls"))

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
Which procedure returns the number of elements in a list?
Visually impaired? Let me spell it for you (wav file) download WAV