+ yaz_log(YLOG_LOG, "metaproxy received SIGTERM");
+ yaz_log(YLOG_LOG, "metaproxy stop");
+ kill(-process_group, SIGTERM); /* kill all children processes as well */
+ _exit(0);
+}
+#endif
+
+static void work_common(void *data)
+{
+ set_log_prefix();
+#if HAVE_UNISTD_H
+ process_group = getpgid(0); // save process group ID
+
+ signal(SIGTERM, sig_term_handler);
+ signal(SIGUSR1, sig_usr1_handler);
+#endif
+ routerp = (mp::RouterFleXML*) data;
+ routerp->start();
+
+ mp::Package pack;
+ pack.router(*routerp).move();
+ yaz_log(YLOG_LOG, "metaproxy stop"); /* only for graceful stop */
+#if HAVE_UNISTD_H
+ kill(-process_group, SIGTERM); /* kill all children processes as well */
+#endif
+ _exit(0);
+}
+
+static void work_debug(void *data)
+{
+ work_common(data);
+}
+
+static void work_normal(void *data)
+{
+#if HAVE_UNISTD_H
+ /* make the current working process group leader */
+ setpgid(0, 0);
+#endif
+ work_common(data);
+}
+
+static int sc_main(
+ yaz_sc_t s,
+ int argc, char **argv)
+{
+ bool test_config = false;
+ const char *fname = 0;
+ int ret;
+ char *arg;
+ unsigned mode = 0;
+ const char *pidfile = 0;
+ const char *uid = 0;
+
+ set_log_prefix();
+
+ while ((ret = options("c{config}:Dh{help}l:m:p:tu:v:V{version}w:X",
+ argv, argc, &arg)) != -2)