From 0e31935343644bb3eba77e2a1f4699ead3b33625 Mon Sep 17 00:00:00 2001 From: Yaakov Selkowitz Date: Mon, 9 Aug 2010 09:01:52 +0200 Subject: Delete stale pid file on cygwin. --- bus/bus.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'bus') 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 #include #include +#include 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 } } -- cgit v1.2.3