spawn: disable signalfd in libev

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-11-14 09:55:29 +01:00
parent a502e19bad
commit e3ba851692
3 changed files with 2 additions and 61 deletions

View File

@ -417,7 +417,7 @@ main(int argc, char **argv)
break; break;
} }
globalconf.loop = ev_default_loop(0); globalconf.loop = ev_default_loop(EVFLAG_NOSIGFD);
/* register function for signals */ /* register function for signals */
ev_signal_init(&sigint, exit_on_signal, SIGINT); ev_signal_init(&sigint, exit_on_signal, SIGINT);

17
luaa.c
View File

@ -238,18 +238,6 @@ luaAe_type(lua_State *L)
return 1; 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. /** Replace various standards Lua functions with our own.
* \param L The Lua VM state. * \param L The Lua VM state.
*/ */
@ -261,11 +249,6 @@ luaA_fixups(lua_State *L)
lua_pushcfunction(L, luaA_mbstrlen); lua_pushcfunction(L, luaA_mbstrlen);
lua_setfield(L, -2, "wlen"); lua_setfield(L, -2, "wlen");
lua_pop(L, 1); 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 */ /* replace next */
lua_pushliteral(L, "next"); lua_pushliteral(L, "next");
lua_pushcfunction(L, luaAe_next); lua_pushcfunction(L, luaAe_next);

44
spawn.c
View File

@ -253,23 +253,6 @@ spawn_launchee_timeout(struct ev_loop *loop, ev_timer *w, int revents)
p_delete(&w); 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. /** Spawn a command.
* \param command_line The command line to launch. * \param command_line The command line to launch.
* \param error A error pointer to fill with the possible error from * \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; return FALSE;
retval = g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, retval = g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH,
spawn_child_callback, NULL, NULL, error); NULL, NULL, NULL, error);
g_strfreev (argv); g_strfreev (argv);
return retval; return retval;
@ -374,29 +357,4 @@ luaA_spawn(lua_State *L)
return 0; 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 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80