[xiph-commits] r9759 - icecast/trunk/icecast/src
karl at svn.xiph.org
karl at svn.xiph.org
Tue Aug 16 14:14:45 PDT 2005
Author: karl
Date: 2005-08-16 14:14:43 -0700 (Tue, 16 Aug 2005)
New Revision: 9759
Modified:
icecast/trunk/icecast/src/main.c
Log:
updates for #599 (dropping of stdin,out,err when using -b) and #630 (pidfile
created before changeowner/chroot)
Modified: icecast/trunk/icecast/src/main.c
===================================================================
--- icecast/trunk/icecast/src/main.c 2005-08-16 16:56:24 UTC (rev 9758)
+++ icecast/trunk/icecast/src/main.c 2005-08-16 21:14:43 UTC (rev 9759)
@@ -63,6 +63,9 @@
#undef CATMODULE
#define CATMODULE "main"
+static int background;
+static char *pidfile = NULL;
+
static void _fatal_error(char *perr)
{
#ifdef WIN32
@@ -132,7 +135,7 @@
int i = 1;
int config_ok = 0;
-
+ background = 0;
if (argc < 2) return -1;
while (i < argc) {
@@ -151,6 +154,7 @@
fprintf(stderr, "FATAL: Unable to fork child!");
exit(1);
}
+ background = 1;
#endif
}
if (strcmp(argv[i], "-v") == 0) {
@@ -300,6 +304,8 @@
/* bind the socket and start listening */
static int _server_proc_init(void)
{
+ ice_config_t *config;
+
if (!_setup_sockets())
return 0;
@@ -308,6 +314,19 @@
return 0;
}
+ config = config_get_config_unlocked();
+ /* recreate the pid file */
+ if (config->pidfile)
+ {
+ FILE *f;
+ pidfile = strdup (config->pidfile);
+ if (pidfile && (f = fopen (config->pidfile, "w")) != NULL)
+ {
+ fprintf (f, "%d\n", (int)getpid());
+ fclose (f);
+ }
+ }
+
return 1;
}
@@ -316,6 +335,12 @@
{
int i;
+ if (background)
+ {
+ fclose (stdin);
+ fclose (stdout);
+ fclose (stderr);
+ }
connection_accept_loop();
for(i=0; i < MAX_LISTEN_SOCKETS; i++)
@@ -402,8 +427,6 @@
int main(int argc, char **argv)
{
int res, ret;
- ice_config_t *config;
- char *pidfile = NULL;
char filename[512];
char pbuf[1024];
@@ -482,19 +505,6 @@
return 1;
}
- config = config_get_config_unlocked();
- /* recreate the pid file */
- if (config->pidfile)
- {
- FILE *f;
- pidfile = strdup (config->pidfile);
- if (pidfile && (f = fopen (config->pidfile, "w")) != NULL)
- {
- fprintf (f, "%d\n", (int)getpid());
- fclose (f);
- }
- }
-
INFO0 (ICECAST_VERSION_STRING " server started");
/* REM 3D Graphics */
More information about the commits
mailing list