File tree 2 files changed +14
-5
lines changed
src/main/clojure/clojure/tools/gitlibs
2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change 1
1
Changelog
2
2
===========
3
3
4
+ * next
5
+ * Don't use future to background the process reading (leaves non-daemon thread)
4
6
* 2.5.186 on Feb 11, 2023
5
7
* Don't block on big git output
6
8
* 2.4.181 on Jun 19, 2022
Original file line number Diff line number Diff line change 24
24
(binding [*out* *err*]
25
25
(apply println msgs)))
26
26
27
- (defn capture
28
- " Reads from input-stream until EOF and returns a String (or nil if 0 length).
29
- Takes same opts as clojure.java.io/copy - :buffer and :encoding"
27
+ (defn- capture
28
+ " Reads from input-stream until EOF and returns a String (or nil if 0 length)."
30
29
[^InputStream input-stream]
31
30
(let [writer (StringWriter. )]
32
31
(jio/copy input-stream writer)
33
32
(let [s (str/trim (.toString writer))]
34
33
(when-not (zero? (.length s))
35
34
s))))
36
35
36
+ (defmacro background
37
+ [& body]
38
+ `(let [result# (promise )]
39
+ (doto (Thread. (fn [] (deliver result# (do ~@body))))
40
+ (.setDaemon true )
41
+ (.start ))
42
+ result#))
43
+
37
44
(defn- run-git
38
45
[& args]
39
46
(let [{:gitlibs/keys [command debug terminal]} @config/CONFIG
44
51
_ (when debug (.redirectError proc-builder ProcessBuilder$Redirect/INHERIT))
45
52
_ (when-not terminal (.put (.environment proc-builder) " GIT_TERMINAL_PROMPT" " 0" ))
46
53
proc (.start proc-builder)
47
- out (future (capture (.getInputStream proc)))
48
- err (future (capture (.getErrorStream proc))) ; ; if debug is true, stderr will be redirected instead
54
+ out (background (capture (.getInputStream proc)))
55
+ err (background (capture (.getErrorStream proc))) ; ; if debug is true, stderr will be redirected instead
49
56
exit (.waitFor proc)]
50
57
{:args command-args, :exit exit, :out @out, :err @err})))
51
58
You can’t perform that action at this time.
0 commit comments