Added support for daemonize to osmo-pcu.
Change-Id: Ia889544e0a350b6bab55da4e4201a617e0241ea2
This commit is contained in:
parent
99278b1050
commit
5a3f3c36d9
|
@ -60,6 +60,7 @@ void *tall_pcu_ctx = NULL;
|
||||||
extern void *bv_tall_ctx;
|
extern void *bv_tall_ctx;
|
||||||
static int quit = 0;
|
static int quit = 0;
|
||||||
static int rt_prio = -1;
|
static int rt_prio = -1;
|
||||||
|
static int daemonize = 0;
|
||||||
static const char *gsmtap_addr = "localhost"; // FIXME: use gengetopt's default value instead
|
static const char *gsmtap_addr = "localhost"; // FIXME: use gengetopt's default value instead
|
||||||
|
|
||||||
static void print_help()
|
static void print_help()
|
||||||
|
@ -75,6 +76,7 @@ static void print_help()
|
||||||
" -V --version print version\n"
|
" -V --version print version\n"
|
||||||
" -r --realtime PRIO Use SCHED_RR with the specified "
|
" -r --realtime PRIO Use SCHED_RR with the specified "
|
||||||
"priority\n"
|
"priority\n"
|
||||||
|
" -D --daemonize Fork the process into a background daemon\n"
|
||||||
" -i --gsmtap-ip The destination IP used for GSMTAP.\n"
|
" -i --gsmtap-ip The destination IP used for GSMTAP.\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -91,12 +93,13 @@ static void handle_options(int argc, char **argv)
|
||||||
{ "mnc", 1, 0, 'n' },
|
{ "mnc", 1, 0, 'n' },
|
||||||
{ "version", 0, 0, 'V' },
|
{ "version", 0, 0, 'V' },
|
||||||
{ "realtime", 1, 0, 'r' },
|
{ "realtime", 1, 0, 'r' },
|
||||||
|
{"daemonize", 0, 0, 'D'},
|
||||||
{ "exit", 0, 0, 'e' },
|
{ "exit", 0, 0, 'e' },
|
||||||
{ "gsmtap-ip", 1, 0, 'i' },
|
{ "gsmtap-ip", 1, 0, 'i' },
|
||||||
{ 0, 0, 0, 0 }
|
{ 0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
c = getopt_long(argc, argv, "hc:m:n:Vr:e:i:",
|
c = getopt_long(argc, argv, "hc:m:n:Vr:De:i:",
|
||||||
long_options, &option_idx);
|
long_options, &option_idx);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
|
@ -130,6 +133,9 @@ static void handle_options(int argc, char **argv)
|
||||||
case 'r':
|
case 'r':
|
||||||
rt_prio = atoi(optarg);
|
rt_prio = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'D':
|
||||||
|
daemonize = 1;
|
||||||
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
fprintf(stderr, "Warning: Option '-e' is deprecated!\n");
|
fprintf(stderr, "Warning: Option '-e' is deprecated!\n");
|
||||||
break;
|
break;
|
||||||
|
@ -329,6 +335,14 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (daemonize) {
|
||||||
|
rc = osmo_daemonize();
|
||||||
|
if (rc < 0) {
|
||||||
|
perror("Error during daemonize");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while (!quit) {
|
while (!quit) {
|
||||||
osmo_gsm_timers_check();
|
osmo_gsm_timers_check();
|
||||||
osmo_gsm_timers_prepare();
|
osmo_gsm_timers_prepare();
|
||||||
|
|
Loading…
Reference in New Issue