*
* Anthony Minessale II <anthmct@yahoo.com>
* Michael Jerris <mike@jerris.com>
+ * Pawel Pierscionek <pawel@voiceworks.pl>
*
*
* switch.c -- Main
{
char pid_path[256] = ""; // full path to the pid file
const char *err = NULL; // error value for return from freeswitch initialization
- int bg = 0; // TRUE if we are running in background mode
+#ifndef WIN32\r
+ int nf = 0; // TRUE if we are running in nofork mode\r
+#endif\r
+ int nc = 0; // TRUE if we are running in noconsole mode\r
int vg = 0; // TRUE if we are running in vg mode
FILE *f; // file handle to the pid file
pid_t pid = 0; //
exit(0);
}
}
+#else
+\r
+ if (argv[x] && !strcmp(argv[x], "-nf")) {\r
+ nf++;\r
+ }
#endif
if (argv[x] && !strcmp(argv[x], "-hp")) {
set_high_priority();
}
if (argv[x] && !strcmp(argv[x], "-nc")) {
- bg++;
- }
+ nc++;\r
+ }\r
if (argv[x] && !strcmp(argv[x], "-vg")) {
vg++;
return freeswitch_kill_background();
}
- if (bg) {
+ if (nc) {
signal(SIGHUP, handle_SIGHUP);
signal(SIGTERM, handle_SIGHUP);
#ifdef WIN32
FreeConsole();
#else
- if ((pid = fork())) {
+ if (!nf && (pid = fork())) {\r
fprintf(stderr, "%d Backgrounding.\n", (int)pid);
exit(0);
}
#endif
}
- if (switch_core_init_and_modload(bg ? lfile : NULL, &err) != SWITCH_STATUS_SUCCESS) {
+ if (switch_core_init_and_modload(nc ? lfile : NULL, &err) != SWITCH_STATUS_SUCCESS) {
fprintf(stderr, "Cannot Initilize [%s]\n", err);
return 255;
}
fprintf(f, "%d", pid = getpid());
fclose(f);
- switch_core_runtime_loop(bg);
+ switch_core_runtime_loop(nc);
return switch_core_destroy(vg);
}