Hi,

On 19.02.2014 21:45, Manuel Kasser wrote:
> I was wondering whether awesome behaves correctly on receiving SIGTERM,
> i. e. doing (more or less) awesome.quit(). I'm not sure how to check
> that myself.

>From awesome.c (all code can be found in the released tarballs or on
git.naquadah.org):

    /* register function for signals */
    g_unix_signal_add(SIGINT, exit_on_signal, NULL);
    g_unix_signal_add(SIGTERM, exit_on_signal, NULL);
    g_unix_signal_add(SIGHUP, restart_on_signal, NULL);

So awesome handles SIGINT, SIGTERM and SIGHUP. Let's look at the function
exit_on_signal():

static gboolean
exit_on_signal(gpointer data)
{
    g_main_loop_quit(globalconf.loop);
    return TRUE;
}

Now we can compare this to the implementation of awesome.quit():

static int
luaA_quit(lua_State *L)
{
    g_main_loop_quit(globalconf.loop);
    return 0;
}

Looks similar enough to me.

(Small side note to the interested reader: g_main_loop_quit() doesn't do
anything if the main loop isn't running yet. This is why awesome.quit() doesn't
work while awesome is starting up. So if you want to confuse people, append
"awesome.quit()" to the end of your rc.lua...)

> I'm asking that because I know from personal experience that there is
> software out there, that shuts down on SIGTERM, but interprets that as a
> crash. *cough* firefox *cough*

Uhm, ok... Why are you SIGTERM'ing your session anyway?

> I was wondering whether shutting down a system with running awesome is
> issuefree by using the system's ability to send SIGTERMs on shutdown.

Well, awesome itself has no permanent state. So even if you kill'd awesome,
nothing bad could happen (I guess...). However, if you SIGTERM all running
processes and expect everything to shut down cleanly, you got a race.

The order in which SIGTERMs are delivered is undefined (AFAIK) and it could
happen that the X server exits before e.g. firefox had the time to react to the
signal. So before firefox gets the signal that tells it to shut down, it sees
that the X server died. Most programs (actually gdk, I think) handle this by
just killing the process. I guess this means "interpret as a crash"...

Cheers,
Uli
-- 
Sent from my Game Boy.

-- 
To unsubscribe, send mail to awesome-unsubscr...@naquadah.org.

Reply via email to