From d2215d3e567f94c98c5355e66227b07a77555046 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Sat, 31 Aug 2024 22:18:23 +0100 Subject: [PATCH] tangc popen retry on short read --- pkgs/tangc/tangc.fnl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/tangc/tangc.fnl b/pkgs/tangc/tangc.fnl index 4bd7a1fd..5ed81de3 100644 --- a/pkgs/tangc/tangc.fnl +++ b/pkgs/tangc/tangc.fnl @@ -18,6 +18,10 @@ (if (< written (# str)) (write-all fd (string.sub str (+ written 1) -1))))) +(fn read-all [fd] + (let [buf (ll.read fd)] + (if (> (# buf) 0) (.. buf (read-all fd)) buf))) + (fn jose [params inputstr] (let [env (ll.environ) argv (doto params (table.insert 1 "jose")) @@ -29,7 +33,7 @@ (ll.close in) (let [output (accumulate [o "" - buf #(match (ll.read out) "" nil s s)] + buf #(match (read-all out) "" nil s s)] (.. o buf))] (values (exited pid) output))))