+static void
+tilda_parse_command_line (gint argc, gchar *argv[])
+{
+ debug_enter ();
+
+ gboolean version = FALSE;
+
+ /* All of the various command-line options */
+ const GOptionEntry cl_opts[] = {
+ { "version", 'V', 0, G_OPTION_ARG_NONE, &version, N_("Show version information"), NULL },
+ { NULL },
+ };
+
+ /* Set up the command-line parser */
+ GError *error = NULL;
+ GOptionContext *context = g_option_context_new (NULL);
+ g_option_context_add_main_entries (context, cl_opts, NULL);
+ g_option_context_add_group (context, gtk_get_option_group (TRUE));
+ g_option_context_parse (context, &argc, &argv, &error);
+ g_option_context_free (context);
+
+ /* Check for unknown options, and give a nice message if there are some */
+ if (error)
+ {
+ g_printerr (_("Error parsing command-line options: %s\n"), error->message);
+ g_printerr (_("The command \"tilda --help\" will show all possible options\n"));
+ g_error_free (error);
+ exit (EXIT_FAILURE);
+ }
+
+ /* If we need to show the version, show it then exit normally */
+ if (version)
+ {
+ g_print ("%s\n\n", TILDA_VERSION);
+
+ g_print ("Copyright (c) 2005-2008 Tristan Sloughter (sloutri@iit.edu)\n");
+ g_print ("Copyright (c) 2005-2008 Ira W. Snyder (tilda@irasnyder.com)\n\n");
+
+ g_print ("This program comes with ABSOLUTELY NO WARRANTY.\n");
+ g_print ("This is free software, and you are welcome to redistribute it\n");
+ g_print ("under certain conditions. See the file COPYING for details.\n");
+
+ exit (EXIT_SUCCESS);
+ }
+}
+
+static void
+tilda_termination_handler (gint signum)
+{
+ debug_enter ();
+ debug_printf ("signum: %d\n", signum);
+
+ gtk_main_quit ();
+}
+
+/* Hook up all system signal handlers */
+static void
+tilda_signal_handlers_init ()
+{
+ struct sigaction sa;
+
+ /* Hook up signal handlers */
+ sa.sa_handler = tilda_termination_handler;
+ sigemptyset (&sa.sa_mask);
+ sa.sa_flags = 0;
+
+ sigaction (SIGINT, &sa, NULL);
+ sigaction (SIGQUIT, &sa, NULL);
+ sigaction (SIGABRT, &sa, NULL);
+ sigaction (SIGTERM, &sa, NULL);
+
+ /* SIGKILL cannot be caught according to sigaction(2) and signal(7) */
+ /* sigaction (SIGKILL, &sa, NULL); */
+}
+