aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2009-11-27 02:54:47 +0800
committerMatthew Barnes <mbarnes@redhat.com>2009-11-27 02:54:47 +0800
commite64794f577ab4bf9ffed0eb88e432ff75ecddd8f (patch)
tree6cd942127a89c9c9077a9305f64c8692d381e6f9
parent04aac07030e328e481df060d4b045b7e6d6117c1 (diff)
downloadgsoc2013-evolution-e64794f577ab4bf9ffed0eb88e432ff75ecddd8f.tar
gsoc2013-evolution-e64794f577ab4bf9ffed0eb88e432ff75ecddd8f.tar.gz
gsoc2013-evolution-e64794f577ab4bf9ffed0eb88e432ff75ecddd8f.tar.bz2
gsoc2013-evolution-e64794f577ab4bf9ffed0eb88e432ff75ecddd8f.tar.lz
gsoc2013-evolution-e64794f577ab4bf9ffed0eb88e432ff75ecddd8f.tar.xz
gsoc2013-evolution-e64794f577ab4bf9ffed0eb88e432ff75ecddd8f.tar.zst
gsoc2013-evolution-e64794f577ab4bf9ffed0eb88e432ff75ecddd8f.zip
Add Evolution's process ID to ~/.evolution/.running.
This is step two of the new --force-shutdown implementation. Read Evolution's PID from ~/.evolution/.running, then invoke Evolution with --quit to ask it to shutdown gracefully, then wait up to X seconds for notification of process termination. If the process still has not terminated, -then- we will kill it.
-rw-r--r--e-util/e-util.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/e-util/e-util.c b/e-util/e-util.c
index 330419c4d4..b5e9f101c4 100644
--- a/e-util/e-util.c
+++ b/e-util/e-util.c
@@ -1323,7 +1323,8 @@ get_lock_filename (void)
static gchar *filename = NULL;
if (G_UNLIKELY (filename == NULL))
- filename = g_build_filename (e_get_user_data_dir (), LOCK_FILE, NULL);
+ filename = g_build_filename (
+ e_get_user_data_dir (), LOCK_FILE, NULL);
return filename;
}
@@ -1331,15 +1332,21 @@ get_lock_filename (void)
gboolean
e_file_lock_create (void)
{
- const gchar *fname = get_lock_filename ();
+ const gchar *filename = get_lock_filename ();
gboolean status = FALSE;
-
- gint fd = g_creat (fname, S_IRUSR|S_IWUSR);
- if (fd == -1) {
- g_warning ("Lock file '%s' creation failed, error %d\n", fname, errno);
- } else {
+ FILE *file;
+
+ file = g_fopen (filename, "w");
+ if (file != NULL) {
+ /* The lock file also serves as a PID file. */
+ g_fprintf (
+ file, "%" G_GINT64_FORMAT "\n",
+ (gint64) getpid ());
+ fclose (file);
status = TRUE;
- close (fd);
+ } else {
+ const gchar *errmsg = g_strerror (errno);
+ g_warning ("Lock file creation failed: %s", errmsg);
}
return status;
@@ -1348,19 +1355,20 @@ e_file_lock_create (void)
void
e_file_lock_destroy (void)
{
- const gchar *fname = get_lock_filename ();
+ const gchar *filename = get_lock_filename ();
- if (g_unlink (fname) == -1) {
- g_warning ("Lock destroy: failed to unlink file '%s'!",fname);
+ if (g_unlink (filename) == -1) {
+ const gchar *errmsg = g_strerror (errno);
+ g_warning ("Lock file deletion failed: %s", errmsg);
}
}
gboolean
e_file_lock_exists (void)
{
- const gchar *fname = get_lock_filename ();
+ const gchar *filename = get_lock_filename ();
- return g_file_test (fname, G_FILE_TEST_EXISTS);
+ return g_file_test (filename, G_FILE_TEST_EXISTS);
}
/**