@@ -35,6 +35,7 @@ public:
void setEnabled(bool enable);
Signal<> activated;
+ Signal<> disconnected;
protected:
void message(Message *msg) override;
@@ -51,6 +51,7 @@ private:
int recvData(void *buffer, size_t length, int32_t *fds, unsigned int num);
void dataNotifier();
+ void EventNotifierDisconnected();
UniqueFD fd_;
bool headerReceived_;
@@ -263,6 +263,15 @@ void EventDispatcherPoll::processNotifiers(const std::vector<struct pollfd> &pol
if (!notifier)
continue;
+ if (pfd.revents & POLLHUP) {
+ LOG(Event, Debug) << "Got signal POLLHUP."
+ << " Disconnecting IPC";
+
+ notifier->disconnected.emit();
+ unregisterEventNotifier(notifier);
+ continue;
+ }
+
/*
* If the file descriptor is invalid, disable the
* notifier immediately.
@@ -131,6 +131,11 @@ void EventNotifier::setEnabled(bool enable)
* parameter.
*/
+/**
+ * \var EventNotifier::disconnected
+ * \brief Signal emitted when the file descriptor is disconnected
+ */
+
void EventNotifier::message(Message *msg)
{
if (msg->type() == Message::ThreadMoveMessage) {
@@ -133,9 +133,17 @@ int IPCUnixSocket::bind(UniqueFD fd)
notifier_ = new EventNotifier(fd_.get(), EventNotifier::Read);
notifier_->activated.connect(this, &IPCUnixSocket::dataNotifier);
+ notifier_->disconnected.connect(
+ this, &IPCUnixSocket::EventNotifierDisconnected);
+
return 0;
}
+void IPCUnixSocket::EventNotifierDisconnected()
+{
+ disconnected.emit();
+}
+
/**
* \brief Close the IPC channel
*