summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2018-06-11 12:58:44 -0700
committerOri Bernstein <ori@eigenstate.org>2018-06-11 13:00:29 -0700
commitce40d0186da04b7cfce7ba21edb6a3b33cd5c198 (patch)
tree9fcc91f444f26bef553e035a96f146682834324a
parentc2f958658791d170d6864525749bf437241790e1 (diff)
downloadmc-ce40d0186da04b7cfce7ba21edb6a3b33cd5c198.tar.gz
Return an error from pledge.
Debatable if it should abort the program instead, but...
-rw-r--r--lib/std/pledge+openbsd.myr13
-rw-r--r--lib/std/pledge.myr2
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/std/pledge+openbsd.myr b/lib/std/pledge+openbsd.myr
index dde6841..762b6f1 100644
--- a/lib/std/pledge+openbsd.myr
+++ b/lib/std/pledge+openbsd.myr
@@ -1,9 +1,18 @@
use sys
+use "errno"
+use "result"
pkg std =
- const pledge : (promise : byte[:], epromise : byte[:] -> void)
+ const pledge : (promise : byte[:], epromise : byte[:] -> result(void, errno))
;;
const pledge = {promise, epromise
- sys.pledge(sys.cstring(promise), sys.cstring(epromise))
+ var r
+
+ r = sys.pledge(sys.cstring(promise), sys.cstring(epromise))
+ if r < 0
+ -> `std.Err (r : errno)
+ else
+ -> `std.Ok void
+ ;;
}
diff --git a/lib/std/pledge.myr b/lib/std/pledge.myr
index 4e58661..c879024 100644
--- a/lib/std/pledge.myr
+++ b/lib/std/pledge.myr
@@ -1,4 +1,6 @@
use sys
+use "errno"
+use "result"
pkg std =
const pledge : (promise : byte[:], epromise : byte[:] -> void)