diff options
author | Harald Welte <laforge@gnumonks.org> | 2010-08-25 19:43:54 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2010-08-25 19:43:54 +0200 |
commit | 2c869efcd3e01d7c111526a3efc140fae5b843af (patch) | |
tree | 33dd151b1931ddee4c4b0f49b26dd316a86d286d /openbsc/src/mgcp | |
parent | 305e2906aae7dbf45204f043394719c9a06c1227 (diff) |
Introduce '-D' commandline option to daemonize processes
This uses the osmo_daemonize() function of libosmocore >= 0.1.18,
and is now implemented for bac_nat, osmo-bsc, bsc_hack, osmo-gbproxy
and bsc_mgcp. This means only osmo-sgsn is missing, which currently
has no option parsing at all.
Diffstat (limited to 'openbsc/src/mgcp')
-rw-r--r-- | openbsc/src/mgcp/mgcp_main.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/openbsc/src/mgcp/mgcp_main.c b/openbsc/src/mgcp/mgcp_main.c index 76f4667f9..21968aa64 100644 --- a/openbsc/src/mgcp/mgcp_main.c +++ b/openbsc/src/mgcp/mgcp_main.c @@ -35,6 +35,7 @@ #include <openbsc/debug.h> #include <osmocore/msgb.h> #include <osmocore/talloc.h> +#include <osmocore/process.h> #include <openbsc/gsm_data.h> #include <osmocore/select.h> #include <openbsc/mgcp.h> @@ -57,6 +58,7 @@ void subscr_put() { abort(); } static struct bsc_fd bfd; static struct mgcp_config *cfg; static int reset_endpoints = 0; +static int daemonize = 0; const char *openbsc_copyright = "Copyright (C) 2009-2010 Holger Freyther and On-Waves\n" @@ -85,11 +87,12 @@ static void handle_options(int argc, char** argv) static struct option long_options[] = { {"help", 0, 0, 'h'}, {"config-file", 1, 0, 'c'}, + {"daemonize", 0, 0, 'D'}, {"version", 0, 0, 'V'}, {0, 0, 0, 0}, }; - c = getopt_long(argc, argv, "hc:V", long_options, &option_index); + c = getopt_long(argc, argv, "hc:VD", long_options, &option_index); if (c == -1) break; @@ -106,6 +109,9 @@ static void handle_options(int argc, char** argv) print_version(1); exit(0); break; + case 'D': + daemonize = 1; + break; default: /* ignore */ break; @@ -259,6 +265,14 @@ int main(int argc, char** argv) /* initialisation */ srand(time(NULL)); + if (daemonize) { + rc = osmo_daemonize(); + if (rc < 0) { + perror("Error during daemonize"); + exit(1); + } + } + /* main loop */ while (1) { bsc_select_main(0); |