Added a flag to the exit signal

This boolean can be used to differentiate between restarts and exits.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Chris Newton 2011-03-20 16:20:02 -06:00 committed by Uli Schlachter
parent 35a5a74744
commit ef3a7bb1b0
3 changed files with 9 additions and 6 deletions

View File

@ -62,14 +62,15 @@ typedef struct
/** Call before exiting. /** Call before exiting.
*/ */
void void
awesome_atexit(void) awesome_atexit(bool restart)
{ {
int screen_nbr, nscreens; int screen_nbr, nscreens;
if(globalconf.hooks.exit != LUA_REFNIL) if(globalconf.hooks.exit != LUA_REFNIL)
luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.exit, 0, 0); luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.exit, 0, 0);
signal_object_emit(globalconf.L, &global_signals, "exit", 0); lua_pushboolean(globalconf.L, restart);
signal_object_emit(globalconf.L, &global_signals, "exit", 1);
a_dbus_cleanup(); a_dbus_cleanup();
@ -251,7 +252,7 @@ exit_on_signal(EV_P_ ev_signal *w, int revents)
void void
awesome_restart(void) awesome_restart(void)
{ {
awesome_atexit(); awesome_atexit(true);
a_exec(globalconf.argv); a_exec(globalconf.argv);
} }
@ -526,7 +527,7 @@ main(int argc, char **argv)
ev_ref(globalconf.loop); ev_ref(globalconf.loop);
ev_io_stop(globalconf.loop, &xio); ev_io_stop(globalconf.loop, &xio);
awesome_atexit(); awesome_atexit(false);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@ -22,8 +22,10 @@
#ifndef AWESOME_AWESOME_H #ifndef AWESOME_AWESOME_H
#define AWESOME_AWESOME_H #define AWESOME_AWESOME_H
#include <stdbool.h>
void awesome_restart(void); void awesome_restart(void);
void awesome_atexit(void); void awesome_atexit(bool restart);
#endif #endif
// 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

2
luaa.c
View File

@ -80,7 +80,7 @@ luaA_exec(lua_State *L)
{ {
const char *cmd = luaL_checkstring(L, 1); const char *cmd = luaL_checkstring(L, 1);
awesome_atexit(); awesome_atexit(false);
a_exec(cmd); a_exec(cmd);
return 0; return 0;