Added daemonize feature to osmo-sip-connector
Change-Id: I400fb5a2619f348cc60e8c9016154afa60424e66
This commit is contained in:
parent
c90829c395
commit
38ab0528b6
18
src/main.c
18
src/main.c
|
@ -46,6 +46,7 @@
|
||||||
|
|
||||||
void *tall_mncc_ctx;
|
void *tall_mncc_ctx;
|
||||||
|
|
||||||
|
static bool daemonize = false;
|
||||||
static char *config_file = "osmo-sip-connector.cfg";
|
static char *config_file = "osmo-sip-connector.cfg";
|
||||||
|
|
||||||
static struct log_info_cat mncc_sip_categories[] = {
|
static struct log_info_cat mncc_sip_categories[] = {
|
||||||
|
@ -79,8 +80,9 @@ static const struct log_info mncc_sip_info = {
|
||||||
static void print_help(void)
|
static void print_help(void)
|
||||||
{
|
{
|
||||||
printf("OsmoSIPcon: MNCC to SIP bridge\n");
|
printf("OsmoSIPcon: MNCC to SIP bridge\n");
|
||||||
printf(" -h --help\tthis text\n");
|
printf(" -h --help\tThis text\n");
|
||||||
printf(" -c --config-file NAME\tThe config file to use [%s]\n", config_file);
|
printf(" -c --config-file NAME\tThe config file to use [%s]\n", config_file);
|
||||||
|
printf(" -D --daemonize\tFork the process into a background daemon\n");
|
||||||
printf(" -V --version\tPrint the version number\n");
|
printf(" -V --version\tPrint the version number\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,11 +93,12 @@ static void handle_options(int argc, char **argv)
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
{"help", 0, 0, 'h'},
|
{"help", 0, 0, 'h'},
|
||||||
{"config-file", 1, 0, 'c'},
|
{"config-file", 1, 0, 'c'},
|
||||||
|
{"daemonize", 0, 0, 'D'},
|
||||||
{"version", 0, 0, 'V' },
|
{"version", 0, 0, 'V' },
|
||||||
{NULL, 0, 0, 0}
|
{NULL, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
c = getopt_long(argc, argv, "hc:V",
|
c = getopt_long(argc, argv, "hc:DV",
|
||||||
long_options, &option_index);
|
long_options, &option_index);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
|
@ -107,6 +110,9 @@ static void handle_options(int argc, char **argv)
|
||||||
case 'c':
|
case 'c':
|
||||||
config_file = optarg;
|
config_file = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'D':
|
||||||
|
daemonize = true;
|
||||||
|
break;
|
||||||
case 'V':
|
case 'V':
|
||||||
print_version(1);
|
print_version(1);
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
|
@ -159,6 +165,14 @@ int main(int argc, char **argv)
|
||||||
calls_init();
|
calls_init();
|
||||||
app_setup(&g_app);
|
app_setup(&g_app);
|
||||||
|
|
||||||
|
if (daemonize) {
|
||||||
|
rc = osmo_daemonize();
|
||||||
|
if (rc < 0) {
|
||||||
|
perror("Error during daemonize");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* marry sofia-sip to glib and glib to libosmocore */
|
/* marry sofia-sip to glib and glib to libosmocore */
|
||||||
loop = g_main_loop_new(NULL, FALSE);
|
loop = g_main_loop_new(NULL, FALSE);
|
||||||
g_source_attach(su_glib_root_gsource(g_app.sip.agent.root),
|
g_source_attach(su_glib_root_gsource(g_app.sip.agent.root),
|
||||||
|
|
Loading…
Reference in New Issue