forked from dan/liminix
add popen2 to anoia.fs
This commit is contained in:
parent
a41839f3d1
commit
1f97409474
@ -65,6 +65,29 @@
|
||||
unknown
|
||||
(error (.. "can't remove " pathname " of mode \"" unknown "\""))))
|
||||
|
||||
(fn popen2 [pname argv envp]
|
||||
(case (ll.pipe2)
|
||||
(cin-s cin-d)
|
||||
(match (ll.pipe2)
|
||||
(cout-s cout-d)
|
||||
(let [(pid err) (ll.fork)]
|
||||
(if (not pid) (error (.. "error: " err))
|
||||
(= pid 0)
|
||||
(do
|
||||
(ll.close cin-d)
|
||||
(ll.close cout-s)
|
||||
(ll.dup2 cin-s 0)
|
||||
(ll.dup2 cout-d 1)
|
||||
(ll.dup2 cout-d 2)
|
||||
(ll.execve pname argv envp)
|
||||
(error "execve failed"))
|
||||
(> pid 0)
|
||||
(do
|
||||
(ll.close cin-s)
|
||||
(ll.close cout-d)))
|
||||
(values pid cin-d cout-s))
|
||||
(nil err) (error (.. "popen pipe out: " err)))
|
||||
(nil err) (error (.. "popen pipe in: " err))))
|
||||
|
||||
{
|
||||
: mktree
|
||||
@ -72,5 +95,6 @@
|
||||
: directory?
|
||||
: dir
|
||||
: file-type
|
||||
: popen2
|
||||
:symlink (fn [from to] (ll.symlink from to))
|
||||
}
|
||||
|
@ -2,31 +2,10 @@
|
||||
(local http (require :fetch))
|
||||
(local { : view : join } (require :fennel))
|
||||
(local { : split : base64 : %%} (require :anoia))
|
||||
(local { : popen2 } (require :anoia.fs))
|
||||
(local ll (require :lualinux))
|
||||
|
||||
(fn popen2 [pname argv envp]
|
||||
(case (ll.pipe2)
|
||||
(cin-s cin-d)
|
||||
(match (ll.pipe2)
|
||||
(cout-s cout-d)
|
||||
(let [(pid err) (ll.fork)]
|
||||
(if (not pid) (error (.. "error: " err))
|
||||
(= pid 0)
|
||||
(do
|
||||
(ll.close cin-d)
|
||||
(ll.close cout-s)
|
||||
(ll.dup2 cin-s 0)
|
||||
(ll.dup2 cout-d 1)
|
||||
(ll.dup2 cout-d 2)
|
||||
(ll.execve pname argv envp)
|
||||
(error "execve failed"))
|
||||
(> pid 0)
|
||||
(do
|
||||
(ll.close cin-s)
|
||||
(ll.close cout-d)))
|
||||
(values pid cin-d cout-s))
|
||||
(nil err) (error (.. "popen pipe out: " err)))
|
||||
(nil err) (error (.. "popen pipe in: " err))))
|
||||
|
||||
|
||||
(local CLEVIS_DEFAULT_THP_LEN 43) ; Length of SHA-256 thumbprint.
|
||||
(local thumbprint-algs ["S256" "S1"])
|
||||
|
Loading…
Reference in New Issue
Block a user