return EXIT_FAILURE;
}
+ DBusError derror;
+ dbus_error_init (& derror);
+
/* thread_local ensures the destructor runs, the destructor doesn't
* run on std::exit without it as per the std::exit specification.
* Otherwise it makes no difference since we're single-threaded. */
- thread_local std::unique_ptr <DBusServer, DBusServer_deleter> server (dbus_server_listen (("unix:path=" + opt.sock_path).c_str(), nullptr));
+ thread_local std::unique_ptr <DBusServer, DBusServer_deleter> server (dbus_server_listen (("unix:path=" + opt.sock_path).c_str(), & derror));
if (!server) {
- std::cerr << "listening on " << opt.sock_path << "failed" << std::endl;
+
+ if (dbus_error_is_set (&derror)) {
+ std::cerr << derror.name << ": " << derror.message << std::endl;
+ dbus_error_free (&derror); // stack var is fine, doesn't actually free the memory
+ } else {
+ std::cerr << "listening on " << opt.sock_path << " failed (unknown error)" << std::endl;
+ }
+
return EXIT_FAILURE;
}