Skip to content

Commit

Permalink
Clean up some leaked descriptors in spork/cc.
Browse files Browse the repository at this point in the history
  • Loading branch information
bakpakin committed Sep 21, 2024
1 parent 4c77afc commit 321093e
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions spork/cc.janet
Original file line number Diff line number Diff line change
Expand Up @@ -472,17 +472,18 @@
(defn visit-execute-quiet
"A function that can be provided as `(dyn *visit*)` that will execute commands quietly."
[cmd inputs outputs message]
(def devnull (sh/devnull))
(os/execute cmd :px {:out devnull :err devnull}))
(with [devnull (sh/devnull)]
(os/execute cmd :px {:out devnull :err devnull})))

###
### Library discovery and self check
###

(defn check-library-exists
"Check if a library exists on the current POSIX system. Will run a test compilation
and return true if the compilation succeeds."
and return true if the compilation succeeds. Libname is passed directly to the compiler/linker, such as `-lm` on GNU/Linux."
[libname &opt binding test-source-code]
(default binding *libs*)
(default test-source-code "int main() { return 0; }")
(def temp (string "_temp" (gensym)))
(def src (string temp "/" (gensym) ".c"))
Expand All @@ -499,10 +500,11 @@
*libs* []]
(setdyn binding [libname])
(compile-and-link-executable executable src)
(def devnull (sh/devnull))
(os/execute [executable] :x {:out devnull :err devnull})
(with [devnull (sh/devnull)]
(os/execute [executable] :x {:out devnull :err devnull}))
true)
([e] false)))))
([e]
false)))))

(defn- search-libs-impl
[dynb libs]
Expand Down

0 comments on commit 321093e

Please sign in to comment.