From 8f7f3962f7a4770e9139d0514deed2eb36c6af88 Mon Sep 17 00:00:00 2001 From: piaip Date: Thu, 11 Jun 2009 17:38:10 +0000 Subject: * allow tunnel/port daemon mode to run within one command. git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4567 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/mbbsd.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'mbbsd/mbbsd.c') diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index ed4706b1..5f27d0bd 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -1768,6 +1768,24 @@ bool parse_argv(int argc, char *argv[], struct ProgramOption *option) } } + if ( option->tunnel_mode && option->nport) + { + // should we do so? + signal_restart(SIGCHLD, reapchild); + + // dual mode: we need to fork. + if (fork() == 0) + { + // ports daemon + option->tunnel_mode = false; + free(option->flag_tunnel_path); + option->flag_tunnel_path = NULL; + } else { + // tunnel mode daemon + option->nport = 0; + } + } + if ( option->tunnel_mode && option->nport != 0) { fprintf(stderr, "you cannot bind ports port in tunnel mode.\n"); return false; -- cgit v1.2.3