summaryrefslogtreecommitdiff
path: root/luxio.c
diff options
context:
space:
mode:
authorRob Kendrick (humdrum) <rjek@rjek.com>2012-03-08 17:18:53 +0000
committerRob Kendrick (humdrum) <rjek@rjek.com>2012-03-08 17:18:53 +0000
commitbff00945a7a11498f5a82d41c1f4d6f5ad937c06 (patch)
tree77e3f8321a61217c894b1a24123c2c03c6c82be5 /luxio.c
parent0e4d64e3e5bf64e78e426656425ce063669eb071 (diff)
downloadluxio-bff00945a7a11498f5a82d41c1f4d6f5ad937c06.tar.gz
kill() binding, expose signal names
Diffstat (limited to 'luxio.c')
-rw-r--r--luxio.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/luxio.c b/luxio.c
index e51e625..a772627 100644
--- a/luxio.c
+++ b/luxio.c
@@ -1312,6 +1312,18 @@ WAITPID_STATUS(WIFCONTINUED)
#undef WAITPID_STATUS
static int
+luxio_kill(lua_State *L)
+{
+ pid_t pid = luaL_checkinteger(L, 1);
+ int sig = luaL_checkinteger(L, 2);
+
+ lua_pushinteger(L, kill(pid, sig));
+ lua_pushinteger(L, errno);
+
+ return 2;
+}
+
+static int
luxio__exit(lua_State *L)
{
int ret = luaL_optinteger(L, 1, 0);
@@ -1360,6 +1372,8 @@ luxio_getenv(lua_State *L)
return 1;
}
+
+
static const struct luaL_Reg
luxio_functions[] = {
{ "open", luxio_open },
@@ -1427,6 +1441,8 @@ luxio_functions[] = {
#endif
#undef WAITPID_STATUS_ENTRY
+ { "kill", luxio_kill },
+
{ "strerror", luxio_strerror },
{ "_exit", luxio__exit },
@@ -1450,6 +1466,8 @@ luxio_bitop_functions[] = {
#include "luxio_constants.h"
+#define NUMERIC_CONSTANT(x) lua_pushstring(L, #x); lua_pushinteger(L, x); lua_settable(L, -3);
+
int
luaopen_luxio(lua_State *L)
{
@@ -1477,5 +1495,13 @@ luaopen_luxio(lua_State *L)
lua_settable(L, -3);
}
+ /* push values that are not compile-time known */
+#ifdef SIGRTMIN
+ NUMERIC_CONSTANT(SIGRTMIN);
+ NUMERIC_CONSTANT(SIGRTMAX);
+#endif
+
return 1;
}
+
+#undef NUMERRIC_CONSTANT