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/nat/bsc_nat.c | |
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/nat/bsc_nat.c')
-rw-r--r-- | openbsc/src/nat/bsc_nat.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/openbsc/src/nat/bsc_nat.c b/openbsc/src/nat/bsc_nat.c index e029b1176..997a57f44 100644 --- a/openbsc/src/nat/bsc_nat.c +++ b/openbsc/src/nat/bsc_nat.c @@ -46,6 +46,7 @@ #include <osmocore/gsm0808.h> #include <osmocore/talloc.h> +#include <osmocore/process.h> #include <osmocore/protocol/gsm_08_08.h> @@ -65,6 +66,7 @@ static struct in_addr local_addr; static struct bsc_fd bsc_listen; static const char *msc_ip = NULL; static struct timer_list sccp_close; +static int daemonize = 0; const char *openbsc_copyright = "Copyright (C) 2010 Holger Hans Peter Freyther and On-Waves\n" @@ -994,6 +996,7 @@ static void print_help() printf(" Some useful help...\n"); printf(" -h --help this text\n"); printf(" -d option --debug=DRLL:DCC:DMM:DRR:DRSL:DNM enable debugging\n"); + printf(" -D --daemonize Fork the process into a background daemon\n"); printf(" -s --disable-color\n"); printf(" -c --config-file filename The config file to use.\n"); printf(" -m --msc=IP. The address of the MSC.\n"); @@ -1106,8 +1109,9 @@ static struct vty_app_info vty_info = { int main(int argc, char** argv) { - talloc_init_ctx(); + int rc; + talloc_init_ctx(); log_init(&log_info); stderr_target = log_target_create_stderr(); @@ -1182,6 +1186,14 @@ int main(int argc, char** argv) signal(SIGUSR1, &signal_handler); signal(SIGPIPE, SIG_IGN); + if (daemonize) { + rc = osmo_daemonize(); + if (rc < 0) { + perror("Error during daemonize"); + exit(1); + } + } + /* recycle timer */ sccp_set_log_area(DSCCP); sccp_close.cb = sccp_close_unconfirmed; |