shithub: lu9-p9

Download patch

ref: 84124e12705e3edc8253e06897718028d476525b
parent: 9cc7744955bddb7e7f067c09a95e70021a536520
author: kvik <kvik@a-b.xyz>
date: Sun Apr 18 21:12:59 EDT 2021

proc: implement p9.alarm()

--- a/p9.c
+++ b/p9.c
@@ -171,6 +171,7 @@
 	
 	{"abort", p9_abort},
 	{"sleep", p9_sleep},
+	{"alarm", p9_alarm},
 	{"rfork", p9_rfork},
 	
 	{nil, nil}
--- a/proc.c
+++ b/proc.c
@@ -18,6 +18,17 @@
 }
 
 static int
+p9_alarm(lua_State *L)
+{
+	long t, rem;
+	
+	t = luaL_checkinteger(L, 1);
+	rem = alarm(t);
+	lua_pushinteger(L, rem);
+	return 1;
+}
+
+static int
 p9_rfork(lua_State *L)
 {
 	int flags, i, n, r;