shithub: mc

Download patch

ref: ce40d0186da04b7cfce7ba21edb6a3b33cd5c198
parent: c2f958658791d170d6864525749bf437241790e1
author: Ori Bernstein <[email protected]>
date: Mon Jun 11 08:58:44 EDT 2018

Return an error from pledge.

	Debatable if it should abort the program instead,
	but...

--- 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
+	;;
 }
--- 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)