shithub: lu9-p9

Download patch

ref: 9cc7744955bddb7e7f067c09a95e70021a536520
parent: 3b15a12f797b9b8c3d0d47d5576afcceccc18fe3
author: kvik <[email protected]>
date: Sun Apr 18 21:08:23 EDT 2021

proc: implement p9.sleep()

--- a/p9.c
+++ b/p9.c
@@ -169,6 +169,8 @@
 	{"getenv", p9_getenv},
 	{"setenv", p9_setenv},
 	
+	{"abort", p9_abort},
+	{"sleep", p9_sleep},
 	{"rfork", p9_rfork},
 	
 	{nil, nil}
--- a/proc.c
+++ b/proc.c
@@ -6,6 +6,18 @@
 }
 
 static int
+p9_sleep(lua_State *L)
+{
+	long t;
+	
+	t = luaL_checkinteger(L, 1);
+	lua_pushboolean(L,
+		sleep(t) == -1 ? 0 : 1
+	);
+	return 1;
+}
+
+static int
 p9_rfork(lua_State *L)
 {
 	int flags, i, n, r;
--- a/test.lua
+++ b/test.lua
@@ -224,7 +224,10 @@
 end
 
 -- Process control
--- No idea how to test this properly.
+-- No idea how to test some of this
+do
+	assert(p9.sleep(0) == true)
+end