From e3ba8516921689c9e5ff72d9b0d2cdc5e3d0fc74 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Sat, 14 Nov 2009 09:55:29 +0100 Subject: [PATCH] spawn: disable signalfd in libev Signed-off-by: Julien Danjou --- awesome.c | 2 +- luaa.c | 17 ----------------- spawn.c | 44 +------------------------------------------- 3 files changed, 2 insertions(+), 61 deletions(-) diff --git a/awesome.c b/awesome.c index 9ff6b4e73..2412f17ae 100644 --- a/awesome.c +++ b/awesome.c @@ -417,7 +417,7 @@ main(int argc, char **argv) break; } - globalconf.loop = ev_default_loop(0); + globalconf.loop = ev_default_loop(EVFLAG_NOSIGFD); /* register function for signals */ ev_signal_init(&sigint, exit_on_signal, SIGINT); diff --git a/luaa.c b/luaa.c index f1a08b6f2..7c0f9c13a 100644 --- a/luaa.c +++ b/luaa.c @@ -238,18 +238,6 @@ luaAe_type(lua_State *L) return 1; } -/** Modified version of os.execute() which use spawn code to reset signal - * handlers correctly before exec()'ing the new program. - * \param L The Lua VM state. - * \return The number of arguments pushed on stack. - */ -static int -luaAe_os_execute(lua_State *L) -{ - lua_pushinteger(L, spawn_system(luaL_optstring(L, 1, NULL))); - return 1; -} - /** Replace various standards Lua functions with our own. * \param L The Lua VM state. */ @@ -261,11 +249,6 @@ luaA_fixups(lua_State *L) lua_pushcfunction(L, luaA_mbstrlen); lua_setfield(L, -2, "wlen"); lua_pop(L, 1); - /* replace os.execute */ - lua_getglobal(L, "os"); - lua_pushcfunction(L, luaAe_os_execute); - lua_setfield(L, -2, "execute"); - lua_pop(L, 1); /* replace next */ lua_pushliteral(L, "next"); lua_pushcfunction(L, luaAe_next); diff --git a/spawn.c b/spawn.c index 0932970c1..829768abd 100644 --- a/spawn.c +++ b/spawn.c @@ -253,23 +253,6 @@ spawn_launchee_timeout(struct ev_loop *loop, ev_timer *w, int revents) p_delete(&w); } -/** This callback is executed in the child process after fork(). It clears the - * signal mask. Without this, child processes would be started with e.g. - * SIGINT blocked if we are compiled against libev 3.8 or newer. - * BEWARE: Pending signals are inherited by child processes. This might mean - * that we receive a signal that was meant for awesome after clearing the signal - * mask! Sadly, we can't do anything about this. - * \param user_data Not used. - */ -static void -spawn_child_callback(gpointer user_data) -{ - sigset_t empty; - - sigemptyset(&empty); - sigprocmask(SIG_SETMASK, &empty, NULL); -} - /** Spawn a command. * \param command_line The command line to launch. * \param error A error pointer to fill with the possible error from @@ -286,7 +269,7 @@ spawn_command(const gchar *command_line, GError **error) return FALSE; retval = g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, - spawn_child_callback, NULL, NULL, error); + NULL, NULL, NULL, error); g_strfreev (argv); return retval; @@ -374,29 +357,4 @@ luaA_spawn(lua_State *L) return 0; } -/** Spawn a program. This works exactly as system() does, but clears the signal mask. - * \param arg The shell command to execute. - * \return The return status of the program. - */ -int -spawn_system(const char *arg) -{ - GError *error; - gboolean retval; - gint status; - static const char *shell = NULL; - if(!shell && !(shell = getenv("SHELL"))) - shell = "/bin/sh"; - char *argv[] = { (char *) shell, (char *) "-c", (char *) arg, NULL }; - - retval = g_spawn_sync(NULL, argv, NULL, 0, spawn_child_callback, - NULL, NULL, NULL, &status, &error); - - if (retval) - return status; - - g_error_free(error); - return -1; -} - // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80