const char *err = NULL; /* error value for return from freeswitch initialization */
#ifndef WIN32
int nf = 0; /* TRUE if we are running in nofork mode */
+ int bf = 0;
char *runas_user = NULL;
char *runas_group = NULL;
#else
"\t-monotonic-clock -- use monotonic clock as timer source\n"
#else
"\t-nf -- no forking\n"
+ "\t-bf -- block until fully started, then fork\n"
"\t-u [user] -- specify user to switch to\n" "\t-g [group] -- specify group to switch to\n"
#endif
"\t-help -- this message\n" "\t-version -- print the version and exit\n"
known_opt++;
}
+ if (local_argv[x] && !strcmp(local_argv[x], "-bf")) {
+ bf++;
+ known_opt++;
+ }
+
if (local_argv[x] && !strcmp(local_argv[x], "-version")) {
fprintf(stdout, "FreeSWITCH version: %s\n", SWITCH_VERSION_FULL);
return 0;
}
if (local_argv[x] && !strcmp(local_argv[x], "-nc")) {
- nc++;
- known_opt++;
+ if (!nf) {
+ nc++;
+ known_opt++;
+ } else {
+ /* The flags -nc and -nf are mutually exclusive. Ignoring -nc. */
+ nc = 0;
+ known_opt++;
+ }
}
if (local_argv[x] && !strcmp(local_argv[x], "-c")) {
#ifdef WIN32
FreeConsole();
#else
- if (!nf) {
+ if (!nf && !bf) {
daemonize();
}
#endif
return 255;
}
+ if(bf) {
+ daemonize();
+ }
+
switch_core_runtime_loop(nc);
destroy_status = switch_core_destroy();