mirror of
https://github.com/janet-lang/janet
synced 2025-09-09 22:36:07 +00:00
Avoid prematurely closing file descriptors when redirecting IO
This commit is contained in:
@@ -94,9 +94,9 @@
|
||||
(assert (= (length buf) 2) "cryptorand appends to buffer"))
|
||||
|
||||
# 80db68210
|
||||
(assert-no-error (os/clock :realtime) "realtime clock")
|
||||
(assert-no-error (os/clock :cputime) "cputime clock")
|
||||
(assert-no-error (os/clock :monotonic) "monotonic clock")
|
||||
(assert-no-error "realtime clock" (os/clock :realtime))
|
||||
(assert-no-error "cputime clock" (os/clock :cputime))
|
||||
(assert-no-error "monotonic clock" (os/clock :monotonic))
|
||||
|
||||
(def before (os/clock :monotonic))
|
||||
(def after (os/clock :monotonic))
|
||||
@@ -129,5 +129,16 @@
|
||||
(string/format "(os/exit %d)" i)] :p))
|
||||
(string "os/execute " i)))
|
||||
|
||||
# os/execute IO redirection
|
||||
(assert-no-error "IO redirection"
|
||||
(defn devnull []
|
||||
(def os (os/which))
|
||||
(def path (if (or (= os :mingw) (= os :windows))
|
||||
"NUL"
|
||||
"/dev/null"))
|
||||
(os/open path :w))
|
||||
(with [dn (devnull)]
|
||||
(os/execute ["ls"] :px {:out dn :err dn})))
|
||||
|
||||
(end-suite)
|
||||
|
||||
|
Reference in New Issue
Block a user