Make status common
[src/app-framework-binder.git] / src / main.c
index d605f2b..b932868 100644 (file)
@@ -113,7 +113,6 @@ static void exit_handler()
                killpg(0, SIGTERM);
        else if (childpid > 0)
                killpg(childpid, SIGTERM);
-       exit(0);
 }
 
 static void on_sigterm(int signum, siginfo_t *info, void *uctx)
@@ -448,11 +447,11 @@ struct startup_req
        struct afb_session *session;
 };
 
-static void startup_call_reply(struct afb_xreq *xreq, int iserror, struct json_object *obj)
+static void startup_call_reply(struct afb_xreq *xreq, int status, struct json_object *obj)
 {
        struct startup_req *sreq = CONTAINER_OF_XREQ(struct startup_req, xreq);
 
-       if (!iserror)
+       if (status >= 0)
                NOTICE("startup call %s returned %s", sreq->current->value, json_object_get_string(obj));
        else {
                ERROR("startup call %s ERROR! %s", sreq->current->value, json_object_get_string(obj));
@@ -530,10 +529,15 @@ static void run_startup_calls()
  | job for starting the daemon
  +--------------------------------------------------------- */
 
-static void start()
+static void start(int signum)
 {
        struct afb_hsrv *hsrv;
 
+       if (signum) {
+               ERROR("start aborted: received signal %s", strsignal(signum));
+               exit(1);
+       }
+
        // ------------------ sanity check ----------------------------------------
        if (config->httpdPort <= 0) {
                ERROR("no port is defined");
@@ -572,6 +576,10 @@ static void start()
                afb_hook_create_xreq(NULL, NULL, NULL, config->tracereq, NULL, NULL);
        if (config->traceditf)
                afb_hook_create_ditf(NULL, config->traceditf, NULL, NULL);
+       if (config->tracesvc)
+               afb_hook_create_svc(NULL, config->tracesvc, NULL, NULL);
+       if (config->traceevt)
+               afb_hook_create_evt(NULL, config->traceevt, NULL, NULL);
 
        /* load bindings */
        apiset_start_list(config->dbus_clients, afb_api_dbus_add_client, "the afb-dbus client");