From 5429690467bd32b1de7ba08685cd44af5fe67ae6 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Tue, 5 Mar 2002 02:43:22 +0000 Subject: [PATCH] try ignoring SIGXFSZ, though I'm not sure what that does exactly. I'm 2002-03-04 Havoc Pennington * src/main.c (main): try ignoring SIGXFSZ, though I'm not sure what that does exactly. I'm hoping it gives me EFBIG. * src/util.c (ensure_logfile): log to a file in /tmp instead of to ~/metacity.log. --- ChangeLog | 8 ++++++++ src/main.c | 7 ++++++- src/util.c | 45 ++++++++++++++++++++++++++++++++++----------- 3 files changed, 48 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 10846d596..9b8fd3b8b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2002-03-04 Havoc Pennington + + * src/main.c (main): try ignoring SIGXFSZ, though I'm not + sure what that does exactly. I'm hoping it gives me EFBIG. + + * src/util.c (ensure_logfile): log to a file in /tmp instead + of to ~/metacity.log. + 2002-03-04 Havoc Pennington * configure.in: fix configure.in since GTK no longer gives us diff --git a/src/main.c b/src/main.c index ecb8cdc71..9e156c518 100644 --- a/src/main.c +++ b/src/main.c @@ -77,7 +77,12 @@ main (int argc, char **argv) act.sa_handler = SIG_IGN; act.sa_mask = empty_mask; act.sa_flags = 0; - sigaction (SIGPIPE, &act, 0); + if (sigaction (SIGPIPE, &act, 0) < 0) + g_printerr ("Failed to register SIGPIPE handler: %s\n", strerror (errno)); +#ifdef SIGXFSZ + if (sigaction (SIGXFSZ, &act, 0) < 0) + g_printerr ("Failed to register SIGXFSZ handler: %s\n", strerror (errno)); +#endif g_set_prgname (argv[0]); diff --git a/src/util.c b/src/util.c index 54fb3b744..8e144fb19 100644 --- a/src/util.c +++ b/src/util.c @@ -19,12 +19,15 @@ * 02111-1307, USA. */ +#include #include "util.h" #include "main.h" #include #include #include +#include +#include static gboolean is_verbose = FALSE; static gboolean is_debugging = FALSE; @@ -36,23 +39,43 @@ ensure_logfile (void) { if (logfile == NULL) { - const char *dir; - char *str; + char *filename = NULL; + char *tmpl; + int fd; + GError *err; - dir = g_get_home_dir (); - str = g_strconcat (dir, "/", "metacity.log", NULL); + tmpl = g_strdup_printf ("metacity-%d-debug-log-XXXXXX", + (int) getpid ()); - /* we want to replace not truncate any old logfile */ - unlink (str); + err = NULL; + fd = g_file_open_tmp (tmpl, + &filename, + &err); + + g_free (tmpl); + + if (err != NULL) + { + meta_warning (_("Failed to open debug log: %s\n"), + err->message); + g_error_free (err); + return; + } + + logfile = fdopen (fd, "w"); - logfile = fopen (str, "w"); - if (logfile == NULL) - meta_warning ("Failed to open log file %s\n", str); + { + meta_warning (_("Failed to fdopen() log file %s: %s\n"), + filename, strerror (errno)); + close (fd); + } else - meta_verbose ("Opened log file %s\n", str); + { + g_print (_("Opened log file %s\n"), filename); + } - g_free (str); + g_free (filename); } }