static int luv_parse_signal(lua_State* L, int slot) { if (lua_isnumber(L, slot)) { return lua_tonumber(L, slot); } if (lua_isstring(L, slot)) { return luv_sig_string_to_num(lua_tostring(L, slot)); } return SIGTERM; }
static int luv_signal_start(lua_State* L) { uv_signal_t* handle = luv_check_signal(L, 1); int signum, ret; if (lua_isnumber(L, 2)) { signum = lua_tointeger(L, 2); } else if (lua_isstring(L, 2)) { signum = luv_sig_string_to_num(luaL_checkstring(L, 2)); luaL_argcheck(L, signum, 2, "Invalid Signal name"); } else { return luaL_argerror(L, 2, "Missing Signal name"); } if (!lua_isnoneornil(L, 3)) { luv_check_callback(L, handle->data, LUV_SIGNAL, 3); } ret = uv_signal_start(handle, luv_signal_cb, signum); if (ret < 0) return luv_error(L, ret); lua_pushinteger(L, ret); return 1; }