From 38f77f46677127b9cc69348a6360579565c64af1 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Tue, 23 Sep 2008 12:41:12 +0100 Subject: [PATCH] bugfix: check if an instance is already running which can happen when developing PackageKit --- src/pk-main.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/pk-main.c b/src/pk-main.c index 88e6ed096..9a874704b 100644 --- a/src/pk-main.c +++ b/src/pk-main.c @@ -32,6 +32,8 @@ #include #include "egg-debug.h" +#include "egg-dbus-monitor.h" + #include "pk-conf.h" #include "pk-engine.h" #include "pk-transaction.h" @@ -167,6 +169,7 @@ main (int argc, char *argv[]) { GMainLoop *loop; DBusGConnection *system_connection; + EggDbusMonitor *monitor; gboolean ret; gboolean verbose = FALSE; gboolean disable_timer = FALSE; @@ -215,6 +218,16 @@ main (int argc, char *argv[]) goto exit_program; } + /* check if an instance is already running */ + monitor = egg_dbus_monitor_new (); + egg_dbus_monitor_assign (monitor, EGG_DBUS_MONITOR_SYSTEM, PK_DBUS_SERVICE); + ret = egg_dbus_monitor_is_connected (monitor); + g_object_unref (monitor); + if (ret) { + g_print ("Already running service which provides %s\n", PK_DBUS_SERVICE); + goto exit_program; + } + /* do stuff on ctrl-c */ signal (SIGINT, pk_main_sigint_handler);