Skip to content
Snippets Groups Projects
Commit 33bd79df authored by Simon McVittie's avatar Simon McVittie
Browse files

Simplify startup and teardown


The signal handler doesn't do anything except exit unsuccessfully,
which is the same thing that would happen if we were interrupted
by a signal. exit() is also not async-signal-safe, so calling it
in this context is undefined behaviour, although _exit() would
be OK.

The cleanup function also doesn't do anything, so don't register it.

The initialization function also doesn't do much, so inline it into
its only caller.

Signed-off-by: default avatarSimon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: default avatarAndré Magalhães <andre.magalhaes@collabora.co.uk>
Differential Revision: https://phabricator.apertis.org/D5501
parent 8c737a7d
No related branches found
No related tags found
No related merge requests found
......@@ -14,42 +14,15 @@
#include <stdlib.h>
#include <glib.h>
static void prestwood_cleanup (void)
{
}
static void prestwood_exit (gint status)
{
exit (status);
}
static void prestwood_handle_exit (void)
{
struct sigaction action;
action.sa_handler = prestwood_exit;
action.sa_flags = 0;
sigaction (SIGINT, &action, NULL);
sigaction (SIGHUP, &action, NULL);
sigaction (SIGTERM, &action, NULL);
atexit (prestwood_cleanup);
}
static void prestwood_initialize (void)
{
if (prestwood_init () != 0)
prestwood_exit (-1);
}
gint main (gint argc, gchar **argv)
{
prestwood_handle_exit();
GMainLoop *mainloop = g_main_loop_new (NULL, TRUE);
if (mainloop == NULL)
return -1;
prestwood_initialize ();
if (prestwood_init () != 0)
return -1;
mainloop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (mainloop);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment