bugfix: check if an instance is already running which can happen when developing PackageKit

This commit is contained in:
Richard Hughes 2008-09-23 12:41:12 +01:00
parent 57dfc86474
commit 38f77f4667

View File

@ -32,6 +32,8 @@
#include <dbus/dbus-glib-lowlevel.h>
#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);