+ goto error;
+
+ /* ready */
+ sd_notify(1, "READY=1");
+ return;
+error:
+ exit(1);
+}
+/*---------------------------------------------------------
+ | main
+ | Parse option and launch action
+ +--------------------------------------------------------- */
+
+int main(int argc, char *argv[])
+{
+ // let's run this program with a low priority
+ nice(20);
+
+ LOGAUTH("afb-daemon");
+
+ sd_fds_init();
+
+ // ------------- Build session handler & init config -------
+ config = afb_config_parse_arguments(argc, argv);
+
+ // --------- run -----------
+ if (config->background) {
+ // --------- in background mode -----------
+ INFO("entering background mode");
+ daemonize();
+ } else {
+ // ---- in foreground mode --------------------
+ INFO("entering foreground mode");
+ }
+
+ /* handle groups */
+ atexit(exit_handler);
+
+ /* ignore any SIGPIPE */
+ signal(SIGPIPE, SIG_IGN);
+
+ /* start */
+ if (sig_monitor_init() < 0) {
+ ERROR("failed to initialise signal handlers");
+ return 1;
+ }
+
+ /* init job processing */
+ if (jobs_init(3, 1, 20) < 0) {
+ ERROR("failed to initialise threading");
+ return 1;
+ }