summaryrefslogtreecommitdiff
path: root/src/kike.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2014-07-16 23:23:03 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2014-07-16 23:56:42 +0200
commit1842fa90dddd257b8b144a8592a893c8e101d3a1 (patch)
treee213fb0ca5ab58a2cd5656f22053b04690a761b6 /src/kike.c
parente00d2079b57afd61bb05b4fc5bea14c67313c24c (diff)
downloadxK-1842fa90dddd257b8b144a8592a893c8e101d3a1.tar.gz
xK-1842fa90dddd257b8b144a8592a893c8e101d3a1.tar.xz
xK-1842fa90dddd257b8b144a8592a893c8e101d3a1.zip
Revise usage of print_{error,fatal}()
Let's limit print_fatal() to unexpected conditions. Also added exit_fatal() to save a few lines of code.
Diffstat (limited to 'src/kike.c')
-rw-r--r--src/kike.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/src/kike.c b/src/kike.c
index 5bcab42..974f80f 100644
--- a/src/kike.c
+++ b/src/kike.c
@@ -65,10 +65,7 @@ static void
setup_signal_handlers (void)
{
if (pipe (g_signal_pipe) == -1)
- {
- print_fatal ("pipe: %s", strerror (errno));
- exit (EXIT_FAILURE);
- }
+ exit_fatal ("%s: %s", "pipe", strerror (errno));
set_cloexec (g_signal_pipe[0]);
set_cloexec (g_signal_pipe[1]);
@@ -87,10 +84,7 @@ setup_signal_handlers (void)
sa.sa_handler = sigterm_handler;
if (sigaction (SIGINT, &sa, NULL) == -1
|| sigaction (SIGTERM, &sa, NULL) == -1)
- {
- print_error ("sigaction: %s", strerror (errno));
- exit (EXIT_FAILURE);
- }
+ exit_fatal ("%s: %s", "sigaction", strerror (errno));
}
// --- IRC token validation ----------------------------------------------------
@@ -1011,10 +1005,8 @@ on_irc_client_available (const struct pollfd *pfd, void *user_data)
// TODO: handle resource exhaustion (EMFILE, ENFILE) specially
// (stop accepting new connections and wait until we close some).
- print_fatal ("%s: %s", "accept", strerror (errno));
-
// FIXME: handle this better, bring the server down cleanly.
- exit (EXIT_FAILURE);
+ exit_fatal ("%s: %s", "accept", strerror (errno));
}
char host[NI_MAXHOST] = "unknown", port[NI_MAXSERV] = "unknown";
@@ -1363,7 +1355,7 @@ main (int argc, char *argv[])
call_write_default_config (optarg, g_config_table);
exit (EXIT_SUCCESS);
default:
- print_fatal ("error in options");
+ print_error ("wrong options");
exit (EXIT_FAILURE);
}
}
@@ -1384,7 +1376,7 @@ main (int argc, char *argv[])
struct error *e = NULL;
if (!read_config_file (&ctx.config, &e))
{
- print_fatal ("error loading configuration: %s", e->message);
+ print_error ("error loading configuration: %s", e->message);
error_free (e);
exit (EXIT_FAILURE);
}