Open both input and output ports to the same fd before using either,

to prevent one closing the fd.
This commit is contained in:
Alex Shinn 2015-05-03 00:17:34 +09:00
parent 3cd5375c28
commit 7cea27ec20

View file

@ -144,9 +144,10 @@
(call-with-locked-file (call-with-locked-file
path path
(lambda (fd) (lambda (fd)
(let* ((str (port->string (open-input-file-descriptor fd))) (let* ((in (open-input-file-descriptor fd))
(res (proc str)) (out (open-output-file-descriptor fd))
(out (open-output-file-descriptor fd))) (str (port->string in))
(res (proc str)))
(set-file-position! out seek/set 0) (set-file-position! out seek/set 0)
(display res out) (display res out)
(file-truncate out (string-size res)) (file-truncate out (string-size res))