aboutsummaryrefslogtreecommitdiffstats
path: root/src/main-afb-daemon.c
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2018-08-28 17:15:12 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2018-08-28 17:35:24 +0200
commita02a1627a954432cc65ec981cada8ba420d7ad2f (patch)
tree3111ce06668dc15d23b26500934ba5bf65341771 /src/main-afb-daemon.c
parent5dd7df31306b95a3fafe6d3238d4553107a6c70f (diff)
Allow choice to trap or not program faults
The binder traps faults by default to recover as much as possible from unexpected errors. Developers may need to remove that behaviour to get core file. This introduces 2 ways to set or remove the trapping of faults: - the environment variable AFB_TRAP_FAULTS - the command line option --trap-faults Both take a boolean value set using on of the following words: 1 yes true on -- enable trapping of faults (the default) 0 no false off -- disable trapping of faults Bug-AGL: SPEC-1702 Change-Id: I6c6a3b933dbda9922a6079c390a601c533d49e55 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/main-afb-daemon.c')
-rw-r--r--src/main-afb-daemon.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/main-afb-daemon.c b/src/main-afb-daemon.c
index 0db84bc1..06aeb58d 100644
--- a/src/main-afb-daemon.c
+++ b/src/main-afb-daemon.c
@@ -50,7 +50,6 @@
#include "afb-hsrv.h"
#include "afb-hreq.h"
#include "afb-xreq.h"
-#include "jobs.h"
#include "afb-session.h"
#include "verbose.h"
#include "afb-common.h"
@@ -59,12 +58,15 @@
#include "afb-hook.h"
#include "afb-hook-flags.h"
#include "afb-debug.h"
-#include "process-name.h"
-#include "wrap-json.h"
#if defined(WITH_SUPERVISION)
# include "afb-supervision.h"
#endif
+#include "process-name.h"
+#include "wrap-json.h"
+#include "jobs.h"
+#include "sig-monitor.h"
+
/*
if SELF_PGROUP == 0 the launched command is the group leader
if SELF_PGROUP != 0 afb-daemon is the group leader
@@ -823,15 +825,23 @@ error:
int main(int argc, char *argv[])
{
- struct json_object *name;
+ struct json_object *obj;
afb_debug("main-entry");
// ------------- Build session handler & init config -------
main_config = afb_config_parse_arguments(argc, argv);
- if (json_object_object_get_ex(main_config, "name", &name)) {
- verbose_set_name(json_object_get_string(name), 0);
- process_name_set_name(json_object_get_string(name));
- process_name_replace_cmdline(argv, json_object_get_string(name));
+ if (sig_monitor_init(
+ !json_object_object_get_ex(main_config, "trap-faults", &obj)
+ || json_object_get_boolean(obj)) < 0) {
+ ERROR("failed to initialise signal handlers");
+ return 1;
+ }
+
+
+ if (json_object_object_get_ex(main_config, "name", &obj)) {
+ verbose_set_name(json_object_get_string(obj), 0);
+ process_name_set_name(json_object_get_string(obj));
+ process_name_replace_cmdline(argv, json_object_get_string(obj));
}
afb_debug("main-args");