-#if defined(ALLOWS_SESSION_FILES)
- // check session dir and create if it does not exist
- if (sessionCheckdir (session) != AFB_SUCCESS) {
- fprintf (stderr,"\nERR: AFB-daemon cannot read/write session dir\n\n");
- exit (1);
+ if (verbosity) fprintf (stderr, "AFB: notice Init config done\n");
+
+ // --------- run -----------
+ if (session->background) {
+ // --------- in background mode -----------
+ if (verbosity) printf ("AFB: Entering background mode\n");
+ daemonize(session);
+ } else {
+ // ---- in foreground mode --------------------
+ if (verbosity) fprintf (stderr,"AFB: notice Foreground mode\n");
+
+ }
+
+ hsrv = start (session->config);
+ if (hsrv == NULL)
+ exit(1);
+
+ if (session->readyfd != 0) {
+ static const char readystr[] = "READY=1";
+ write(session->readyfd, readystr, sizeof(readystr) - 1);
+ close(session->readyfd);