Revision
15234
Author
mikej
Date
2009-10-26 16:46:21 -0500 (Mon, 26 Oct 2009)

Log Message

fix regression from -run addition and better handling of -stop

Modified Paths

Diff

Modified: freeswitch/trunk/src/switch.c (15233 => 15234)


--- freeswitch/trunk/src/switch.c	2009-10-26 19:57:28 UTC (rev 15233)
+++ freeswitch/trunk/src/switch.c	2009-10-26 21:46:21 UTC (rev 15234)
@@ -276,7 +276,7 @@
 	int local_argc = argc;
 	char *arg_argv[128] = { 0 };
 	char *usageDesc;
-	int alt_dirs = 0;
+	int alt_dirs = 0, log_set = 0, run_set = 0, kill = 0;
 	int known_opt;
 	int high_prio = 0;
 #ifdef __sun
@@ -498,7 +498,7 @@
 		}
 
 		if (local_argv[x] && !strcmp(local_argv[x], "-stop")) {
-				return freeswitch_kill_background();
+			kill++;
 		}
 
 		if (local_argv[x] && !strcmp(local_argv[x], "-nc")) {
@@ -554,6 +554,7 @@
 				}
 				strcpy(SWITCH_GLOBAL_dirs.log_dir, local_argv[x]);
 				alt_dirs++;
+				log_set++;
 			} else {
 				fprintf(stderr, "When using -log you must specify a log directory\n");
 				return 255;
@@ -570,6 +571,7 @@
 					return 255;
 				}
 				strcpy(SWITCH_GLOBAL_dirs.run_dir, local_argv[x]);
+				run_set++;
 			} else {
 				fprintf(stderr, "When using -run you must specify a pid directory\n");
 				return 255;
@@ -631,7 +633,15 @@
 			exit(0);
 		}
 	}
+	
+	if (log_set && !run_set) {
+		strcpy(SWITCH_GLOBAL_dirs.run_dir, SWITCH_GLOBAL_dirs.log_dir);
+	}
 
+	if (kill) {
+		return freeswitch_kill_background();
+	}
+
 	if (apr_initialize() != SWITCH_STATUS_SUCCESS) {
 		fprintf(stderr, "FATAL ERROR! Could not initialize APR\n");
 		return 255;