CLEANUP: checks: make use of the post-init registration to start checks

Instead of calling the checks directly from the init code, we now
register the start_checks() function to be run at this point. This
also allows to unexport the check init function and to remove one
include from haproxy.c.
diff --git a/include/proto/checks.h b/include/proto/checks.h
index bf771ea..3c6eb7f 100644
--- a/include/proto/checks.h
+++ b/include/proto/checks.h
@@ -27,7 +27,6 @@
 
 const char *get_check_status_description(short check_status);
 const char *get_check_status_info(short check_status);
-int start_checks();
 void __health_adjust(struct server *s, short status);
 int trigger_resolution(struct server *s);
 
diff --git a/src/checks.c b/src/checks.c
index 8eb2c7a..b1e4549 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -2331,9 +2331,10 @@
 
 /*
  * Start health-check.
- * Returns 0 if OK, -1 if error, and prints the error in this case.
+ * Returns 0 if OK, ERR_FATAL on error, and prints the error in this case.
  */
-int start_checks() {
+static int start_checks()
+{
 
 	struct proxy *px;
 	struct server *s;
@@ -2352,7 +2353,7 @@
 			if (s->slowstart) {
 				if ((t = task_new()) == NULL) {
 					Alert("Starting [%s:%s] check: out of memory.\n", px->id, s->id);
-					return -1;
+					return ERR_ALERT | ERR_FATAL;
 				}
 				/* We need a warmup task that will be called when the server
 				 * state switches from down to up.
@@ -2396,7 +2397,7 @@
 		if ((px->options2 & PR_O2_CHK_ANY) == PR_O2_EXT_CHK) {
 			if (init_pid_list()) {
 				Alert("Starting [%s] check: out of memory.\n", px->id);
-				return -1;
+				return ERR_ALERT | ERR_FATAL;
 			}
 		}
 
@@ -2405,17 +2406,17 @@
 			if (s->check.state & CHK_ST_CONFIGURED) {
 				if (s->check.type == PR_O2_EXT_CHK) {
 					if (!prepare_external_check(&s->check))
-						return -1;
+						return ERR_ALERT | ERR_FATAL;
 				}
 				if (!start_check_task(&s->check, mininter, nbcheck, srvpos))
-					return -1;
+					return ERR_ALERT | ERR_FATAL;
 				srvpos++;
 			}
 
 			/* A task for a auxiliary agent check */
 			if (s->agent.state & CHK_ST_CONFIGURED) {
 				if (!start_check_task(&s->agent, mininter, nbcheck, srvpos)) {
-					return -1;
+					return ERR_ALERT | ERR_FATAL;
 				}
 				srvpos++;
 			}
@@ -3455,6 +3456,12 @@
 	return 0;
 }
 
+__attribute__((constructor))
+static void __check_init(void)
+{
+	hap_register_post_check(start_checks);
+}
+
 
 /*
  * Local variables:
diff --git a/src/haproxy.c b/src/haproxy.c
index 780ca3c..5d43cf3 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -89,7 +89,6 @@
 #include <proto/auth.h>
 #include <proto/backend.h>
 #include <proto/channel.h>
-#include <proto/checks.h>
 #include <proto/connection.h>
 #include <proto/fd.h>
 #include <proto/filters.h>
@@ -946,9 +945,6 @@
 		}
 	}
 
-	if (start_checks() < 0)
-		exit(1);
-
 	list_for_each_entry(pcf, &post_check_list, list) {
 		err_code |= pcf->fct();
 		if (err_code & (ERR_ABORT|ERR_FATAL))