+static int
+is_application_running(std::string appid, std::unordered_map<std::string, HS_Client*> client_list)
+{
+ bool app_still_running = false;
+
+ std::string id(appid);
+ auto ip = client_list.find(id);
+
+ // this will always be case as the removeClientCtxt() is never called as
+ // clients do not handle the subscribe at all at this point. Not only that
+ // but is redudant but we keep at as it to highlight the fact that we're
+ // missing a feature to check if applications died or not (legitimate or not).
+ //
+ // Using ps (HS_AfmMainProxy::ps -- a sync version of checking if running
+ // applications) seem to block in afm-system-daemon (see SPEC-3902), and
+ // doing w/ it with an async version of ps doesn't work because we don't
+ // have a valid clientCtx (required, and only possible if the application
+ // subscribed themselves, which no longer happens)
+ //
+ // FIXME: We need another way of handling this would be necessary to correctly
+ // handle the case where the app died.
+ if (ip != client_list.end()) {
+ app_still_running = true;
+ }
+
+ // > 0 means err
+ return app_still_running != true;
+}
+