Initial project import
This commit is contained in:
commit
23f2d29e32
11957 files changed
+1754577
No files matched your search
@@ -0,0 +1,24 @@
|
||||
module util
|
||||
|
||||
import os
|
||||
|
||||
// TODO `select` doesn't work with time.Duration for some reason
|
||||
pub fn execute_with_timeout(cmd string, timeout i64) ?os.Result {
|
||||
ch := chan os.Result{cap: 1}
|
||||
spawn fn [cmd] (c chan os.Result) {
|
||||
res := os.execute(cmd)
|
||||
c <- res
|
||||
}(ch)
|
||||
select {
|
||||
a := <-ch {
|
||||
return a
|
||||
}
|
||||
// timeout {
|
||||
// 1000 * time.millisecond {
|
||||
// timeout * time.millisecond {
|
||||
timeout * 1_000_000 {
|
||||
return none
|
||||
}
|
||||
}
|
||||
return os.Result{}
|
||||
}
|
||||
Reference in new issue
Block a user