From: Adam Dickmeiss Date: Tue, 28 Sep 2010 10:19:42 +0000 (+0200) Subject: Avoid setpgid if debug mode is in use (option -X). X-Git-Tag: v1.2.3~2^2 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=a847bcf76f8fc2eb6b3ca656e626af8d5fa5db33;p=metaproxy-moved-to-github.git Avoid setpgid if debug mode is in use (option -X). --- diff --git a/src/metaproxy_prog.cpp b/src/metaproxy_prog.cpp index b598a81..fb9d1e2 100644 --- a/src/metaproxy_prog.cpp +++ b/src/metaproxy_prog.cpp @@ -56,23 +56,29 @@ static void sig_term_handler(int s) } #endif -static void handler(void *data) +static void handler_debug(void *data) { - routerp = (mp::RouterFleXML*) data; - -#if HAVE_UNISTD_H - /* make the current working process group leader */ - setpgid(0, 0); +#if HAVE_UNISTD_H process_group = getpgid(0); // save process group ID signal(SIGTERM, sig_term_handler); #endif + routerp = (mp::RouterFleXML*) data; routerp->start(); mp::Package pack; pack.router(*routerp).move(); /* should never exit */ } +static void handler_normal(void *data) +{ +#if HAVE_UNISTD_H + /* make the current working process group leader */ + setpgid(0, 0); +#endif + handler_debug(data); +} + static int sc_main( yaz_sc_t s, int argc, char **argv) @@ -199,7 +205,8 @@ static int sc_main( yaz_sc_running(s); - yaz_daemon("metaproxy", mode, handler, router, pidfile, uid); + yaz_daemon("metaproxy", mode, mode == YAZ_DAEMON_DEBUG ? + handler_debug : handler_normal, router, pidfile, uid); } catch (std::logic_error &e) { yaz_log (YLOG_FATAL,"std::logic error: %s" , e.what() );