Crash protection for gnome-session



I experienced a gnome-session crash, and lost some unsaved work that I had
done. Unfortunately, I managed to remove to core file so I can't provide a
stack trace.

But I made a little wrapper script around gnome-session that lets me save
stuff before crashing. It seems to work, although I haven't had a real crash
so far, I've simulated one by killing gnome-session brutally... Will it work
for real?

In my .Xclients I have the following:

exec start-gnome

Where the script start-gnome contains:

#!/bin/sh

if gnome-session; then
    # everything went ok
    exit 0
fi

exec crash_alert

crash_alert is a very tiny gnome app that just brings up a message box
to tell me something went wrong and to save everything and then press Ok.
I attached the tiny c-file.

Of course the ultimate goal is the have a bug-free gnome-session but before
that, this little tool can be useful :)

By the way, is it ok to bring up a gnome-dialog in main() and just dont
care about having a gtk_main()? It seems to work...

This is a 5 minute hack, it could surely be made better. Maybe even have an
option to restart the session. What do I know? ;)

Richard

 
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */

/* 
 * crash-alert. Lets the user save unsaved work in case of gnome-session crash
 */                                                                    

#include <gnome.h>

int main (int argc, char **argv)
{
	GtkWidget *dialog;
	
	gnome_init("Crash-alert", NULL, argc, argv);
	
	dialog = gnome_message_box_new ("Gnome-session seems to have crashed due to a bug.\nPlease save any unsaved work and press OK to end\nthe session.", 
									GNOME_MESSAGE_BOX_ERROR, GNOME_STOCK_BUTTON_OK, NULL);
	gnome_dialog_run (GNOME_DIALOG (dialog));
	
	return 0;
}





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]