[mobile] Adding option to run as daemon
This commit is contained in:
parent
c9927c72ea
commit
4d077b0e4c
|
@ -30,6 +30,7 @@
|
||||||
#include <osmocom/core/gsmtap_util.h>
|
#include <osmocom/core/gsmtap_util.h>
|
||||||
#include <osmocom/core/gsmtap.h>
|
#include <osmocom/core/gsmtap.h>
|
||||||
#include <osmocom/core/signal.h>
|
#include <osmocom/core/signal.h>
|
||||||
|
#include <osmocom/core/application.h>
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
|
@ -55,6 +56,7 @@ unsigned short vty_port = 4247;
|
||||||
int debug_set = 0;
|
int debug_set = 0;
|
||||||
char *config_dir = NULL;
|
char *config_dir = NULL;
|
||||||
int use_mncc_sock = 0;
|
int use_mncc_sock = 0;
|
||||||
|
int daemonize = 0;
|
||||||
|
|
||||||
int mncc_recv_socket(struct osmocom_ms *ms, int msg_type, void *arg);
|
int mncc_recv_socket(struct osmocom_ms *ms, int msg_type, void *arg);
|
||||||
|
|
||||||
|
@ -86,6 +88,7 @@ static void print_help()
|
||||||
printf(" -v --vty-port The VTY port number to telnet to. "
|
printf(" -v --vty-port The VTY port number to telnet to. "
|
||||||
"(default %u)\n", vty_port);
|
"(default %u)\n", vty_port);
|
||||||
printf(" -d --debug Change debug flags.\n");
|
printf(" -d --debug Change debug flags.\n");
|
||||||
|
printf(" -D --daemonize Run as daemon\n");
|
||||||
printf(" -m --mncc-sock Disable built-in MNCC handler and "
|
printf(" -m --mncc-sock Disable built-in MNCC handler and "
|
||||||
"offer socket\n");
|
"offer socket\n");
|
||||||
}
|
}
|
||||||
|
@ -99,11 +102,12 @@ static void handle_options(int argc, char **argv)
|
||||||
{"gsmtap-ip", 1, 0, 'i'},
|
{"gsmtap-ip", 1, 0, 'i'},
|
||||||
{"vty-port", 1, 0, 'v'},
|
{"vty-port", 1, 0, 'v'},
|
||||||
{"debug", 1, 0, 'd'},
|
{"debug", 1, 0, 'd'},
|
||||||
|
{"daemonize", 0, 0, 'D'},
|
||||||
{"mncc-sock", 0, 0, 'm'},
|
{"mncc-sock", 0, 0, 'm'},
|
||||||
{0, 0, 0, 0},
|
{0, 0, 0, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
c = getopt_long(argc, argv, "hi:v:d:m",
|
c = getopt_long(argc, argv, "hi:v:d:Dm",
|
||||||
long_options, &option_index);
|
long_options, &option_index);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
|
@ -124,6 +128,9 @@ static void handle_options(int argc, char **argv)
|
||||||
log_parse_category_mask(stderr_target, optarg);
|
log_parse_category_mask(stderr_target, optarg);
|
||||||
debug_set = 1;
|
debug_set = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'D':
|
||||||
|
daemonize = 1;
|
||||||
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
use_mncc_sock = 1;
|
use_mncc_sock = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -208,6 +215,13 @@ int main(int argc, char **argv)
|
||||||
signal(SIGTERM, sighandler);
|
signal(SIGTERM, sighandler);
|
||||||
signal(SIGPIPE, sighandler);
|
signal(SIGPIPE, sighandler);
|
||||||
|
|
||||||
|
if (daemonize) {
|
||||||
|
printf("Running as daemon\n");
|
||||||
|
rc = osmo_daemonize();
|
||||||
|
if (rc)
|
||||||
|
fprintf(stderr, "Failed to run as daemon\n");
|
||||||
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
l23_app_work(&quit);
|
l23_app_work(&quit);
|
||||||
if (quit && llist_empty(&ms_list))
|
if (quit && llist_empty(&ms_list))
|
||||||
|
|
Loading…
Reference in New Issue