summaryrefslogtreecommitdiff
path: root/bus
diff options
context:
space:
mode:
authorYaakov Selkowitz <yselkowitz@users.sourceforge.net>2010-08-09 09:01:52 +0200
committerRalf Habacker <ralf.habacker@freenet.de>2010-08-10 08:25:47 +0200
commit0e31935343644bb3eba77e2a1f4699ead3b33625 (patch)
treecf2330107b80b7a8f0442d5d39c9e3ba7bf7a616 /bus
parente5d0069c8f2b047b062df03052b7a997ab30c3ca (diff)
Delete stale pid file on cygwin.
Diffstat (limited to 'bus')
-rw-r--r--bus/bus.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/bus/bus.c b/bus/bus.c
index 1f8994c5..b8ef6167 100644
--- a/bus/bus.c
+++ b/bus/bus.c
@@ -36,6 +36,7 @@
#include <dbus/dbus-hash.h>
#include <dbus/dbus-credentials.h>
#include <dbus/dbus-internals.h>
+#include <signal.h>
struct BusContext
{
@@ -311,10 +312,29 @@ process_config_first_time_only (BusContext *context,
if (_dbus_stat (&u, &stbuf, NULL))
{
+#ifdef DBUS_CYGWIN
+ DBusString p;
+ long /* int */ pid;
+
+ _dbus_string_init (&p);
+ _dbus_file_get_contents(&p, &u, NULL);
+ _dbus_string_parse_int(&p, 0, &pid, NULL);
+ _dbus_string_free(&p);
+
+ if ((kill((int)pid, 0))) {
+ dbus_set_error(NULL, DBUS_ERROR_FILE_EXISTS,
+ "pid %ld not running, removing stale pid file\n",
+ pid);
+ _dbus_delete_file(&u, NULL);
+ } else {
+#endif
dbus_set_error (error, DBUS_ERROR_FAILED,
"The pid file \"%s\" exists, if the message bus is not running, remove this file",
pidfile);
goto failed;
+#ifdef DBUS_CYGWIN
+ }
+#endif
}
}