read-line hangs reading /proc files in linux
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
| SBCL |
Medium
|
Unassigned |
Bug Description
read-line hangs trying to read a file from /proc directory on linux. Tested on a freshly built sbcl from cvs, using clbuild. Also present in sbcl 1.0.29 on debian and ubuntu, with original distro packages, in 32-bit and 64-bit architectures
fvides@
(running SBCL from: .)
This is SBCL 1.0.31.2, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://
SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
* (with-open-file (s #p"/proc/mounts")
(break "Never reach this"))
fvides@
(running SBCL from: .)
SBCL 1.0.31.2
fvides@
Linux gemini 2.6.26-
* *FEATURES*
(:ANSI-CL :COMMON-LISP :SBCL :SB-DOC :SB-TEST :SB-LDB :SB-PACKAGE-LOCKS
:SB-UNICODE :SB-EVAL :SB-SOURCE-
:ELF :LINUX :GENCGC :STACK-
:LINKAGE-TABLE :COMPARE-
:RAW-INSTANCE-
:STACK-
:CYCLE-COUNTER :COMPLEX-FLOAT-VOPS :FLOAT-EQL-VOPS :INLINE-CONSTANTS
:OS-PROVIDES-
Nikodemus Siivola (nikodemus) wrote : | #2 |
This is due to REFILL-INPUT-BUFFER in src/code/
Changed in sbcl: | |
status: | New → Confirmed |
importance: | Undecided → Medium |
tags: | added: os-linux streams |
tags: | added: serve-event |
Alexey Lebedeff (binarin) wrote : | #3 |
In SBCL 1.0.34.0.debian on Linux 2.6.30 following also hangs, very probably for same reasons:
(let* ((proc (sb-ext:run-program "cat" '("file-
:search t :output :stream))
(pipe-stream (sb-ext:
(format t "~A~%" (read-line pipe-stream)))
By strace, the 'cat' process is hanging on 'write' call. Only when I kill the 'cat' process, sbcl unblocks and continues execution
Alexey Lebedeff (binarin) wrote : | #4 |
Ah, sorry i was wrong, because I missed the 'wait' option in run-program documentation.
Alastair Bridgewater (alastair-bridgewater) wrote : Re: [Bug 425199] Re: read-line hangs reading /proc files in linux | #5 |
As a bit of a workaround, you might find the following of use (from lh-usb):
(defun read-usb-devices ()
"Returns the contents of /proc/bus/
(with-open-file (devlist "/proc/
;; This "file" violates the usual contract of select(2). An
;; input-ready condition on the file indicates that a device has
;; been connected or disconnected, not that there happens to be
;; more data to read. No select(2) means no serve-event. No
;; serve-event means that we can't use the standard Lisp file I/O,
;; and have to do our own buffering... And, while we're at it, we
;; won't bother doing our own error handling.
(let* ((buffers
(loop for buf = (make-array #x200
:element-type '(unsigned-byte 8)
:fill-pointer t)
for (len error) = (multiple-
#x200))
until (or (null len) (zerop len))
do (setf (fill-pointer buf) len)
collect buf))
(combined-
'(vector (unsigned-byte 8)) buffers))
(file-contents (sb-ext:
file-
Changed in sbcl: | |
assignee: | nobody → Nikodemus Siivola (nikodemus) |
status: | Confirmed → In Progress |
Nikodemus Siivola (nikodemus) wrote : | #6 |
Fixed in SBCL 1.0.42.41.
Changed in sbcl: | |
assignee: | Nikodemus Siivola (nikodemus) → nobody |
status: | In Progress → Fix Committed |
Changed in sbcl: | |
status: | Fix Committed → Fix Released |
Works as expected in ECLS and CLISP.