core: allow warnings to be fatal with --g-fatal-warnings

This commit is contained in:
Bastien Nocera 2009-05-20 13:03:39 -04:00 committed by Dan Williams
parent 15e64d31ea
commit 0f6ed55ef9

View file

@ -252,6 +252,7 @@ main (int argc, char *argv[])
{
GOptionContext *opt_ctx = NULL;
gboolean become_daemon = FALSE;
gboolean g_fatal_warnings = FALSE;
char * pidfile = NULL;
char * user_pidfile = NULL;
gboolean success;
@ -264,6 +265,7 @@ main (int argc, char *argv[])
GOptionEntry options[] = {
{"no-daemon", 0, 0, G_OPTION_ARG_NONE, &become_daemon, "Don't become a daemon", NULL},
{ "g-fatal-warnings", 0, 0, G_OPTION_ARG_NONE, &g_fatal_warnings, "Make all warnings fatal", NULL },
{"pid-file", 0, 0, G_OPTION_ARG_FILENAME, &user_pidfile, "Specify the location of a PID file", "filename"},
{NULL}
};
@ -314,6 +316,14 @@ main (int argc, char *argv[])
write_pidfile (pidfile);
}
if (g_fatal_warnings) {
GLogLevelFlags fatal_mask;
fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
g_log_set_always_fatal (fatal_mask);
}
/*
* Set the umask to 0022, which results in 0666 & ~0022 = 0644.
* Otherwise, if root (or an su'ing user) has a wacky umask, we could