Commit e8eddcd7 authored by Michael Smith's avatar Michael Smith

Make icecast keep parsing command line options after -c.

Error message if fork fails.

All untested; the conversion broke the build.


svn path=/icecast/trunk/icecast/; revision=6152
parent ba356d5e
...@@ -133,10 +133,12 @@ static void _shutdown_subsystems(void) ...@@ -133,10 +133,12 @@ static void _shutdown_subsystems(void)
xmlCleanupParser(); xmlCleanupParser();
} }
static int _parse_config_file(int argc, char **argv, char *filename, int size) static int _parse_config_opts(int argc, char **argv, char *filename, int size)
{ {
int i = 1; int i = 1;
int processID = 0; int processID = 0;
int config_ok = 0;
if (argc < 2) return -1; if (argc < 2) return -1;
...@@ -146,7 +148,11 @@ static int _parse_config_file(int argc, char **argv, char *filename, int size) ...@@ -146,7 +148,11 @@ static int _parse_config_file(int argc, char **argv, char *filename, int size)
fprintf(stdout, "Starting icecast2\nDetaching from the console\n"); fprintf(stdout, "Starting icecast2\nDetaching from the console\n");
if ((processID = (int)fork()) > 0) { if ((processID = (int)fork()) > 0) {
/* exit the parent */ /* exit the parent */
_exit(0); exit(0);
}
else {
fprintf(stderr, "FATAL: Unable to fork child!");
exit(1);
} }
#endif #endif
} }
...@@ -159,7 +165,7 @@ static int _parse_config_file(int argc, char **argv, char *filename, int size) ...@@ -159,7 +165,7 @@ static int _parse_config_file(int argc, char **argv, char *filename, int size)
if (i + 1 < argc) { if (i + 1 < argc) {
strncpy(filename, argv[i + 1], size-1); strncpy(filename, argv[i + 1], size-1);
filename[size-1] = 0; filename[size-1] = 0;
return 1; config_ok = 1;
} else { } else {
return -1; return -1;
} }
...@@ -167,7 +173,10 @@ static int _parse_config_file(int argc, char **argv, char *filename, int size) ...@@ -167,7 +173,10 @@ static int _parse_config_file(int argc, char **argv, char *filename, int size)
i++; i++;
} }
return -1; if(config_ok)
return 1;
else
return -1;
} }
static int _start_logging(void) static int _start_logging(void)
...@@ -369,7 +378,7 @@ int main(int argc, char **argv) ...@@ -369,7 +378,7 @@ int main(int argc, char **argv)
/* parse the '-c icecast.xml' option /* parse the '-c icecast.xml' option
** only, so that we can read a configfile ** only, so that we can read a configfile
*/ */
res = _parse_config_file(argc, argv, filename, 512); res = _parse_config_opts(argc, argv, filename, 512);
if (res == 1) { if (res == 1) {
/* startup all the modules */ /* startup all the modules */
_initialize_subsystems(); _initialize_subsystems();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment