Dale Ghent
2004-Aug-06  14:57 UTC
[icecast-dev] [PATCH] main.c: use pid_t and cleanup command line opts parsing.
Use pid_t instead of int for variable processID
Add error message if fork() fails.
Do not immediately return() after encountering the -c flag - we may still
have additional argv members to find and take care of.
/dale
-------------- next part --------------
Index: main.c
==================================================================RCS file:
/usr/local/cvsroot/icecast/src/main.c,v
retrieving revision 1.40
diff -u -r1.40 main.c
--- a/main.c	9 Mar 2004 23:52:20 -0000	1.40
+++ b/main.c	20 Mar 2004 20:26:56 -0000
@@ -136,17 +136,24 @@
 static int _parse_config_file(int argc, char **argv, char *filename, int size)
 {
     int i = 1;
-    int    processID = 0;
+
+#ifndef WIN32
+    pid_t processID;
+#endif
 
     if (argc < 2) return -1;
 
     while (i < argc) {
         if (strcmp(argv[i], "-b") == 0) {
 #ifndef WIN32
-            fprintf(stdout, "Starting icecast2\nDetaching from the
console\n");
-            if ((processID = (int)fork()) > 0) {
+            fprintf(stdout, "Detaching from the console...\n");
+
+            if ((processID = fork()) > 0)
                 /* exit the parent */
-                _exit(0);
+                exit(0);
+            else if (processID == -1) {
+                fprintf(stderr, "FATAL: Unable to fork child!");
+                exit(1);
             }
 #endif
         }
@@ -159,7 +166,6 @@
             if (i + 1 < argc) {
                 strncpy(filename, argv[i + 1], size-1);
                 filename[size-1] = 0;
-                return 1;
             } else {
                 return -1;
             }
+mb+rzqk7&zzmy:.mkabzhj]zrj)
'+a{
+v&{ay,ry'rzg-b"V	~)mz
Dale Ghent
2004-Aug-06  14:57 UTC
[icecast-dev] [PATCH] main.c: use pid_t and cleanup command line opts parsing.
On Mar 21, 2004, at 9:04 PM, Michael Smith wrote:> Obviously not even tested; it is clear that with this patch icecast > will > always refuse to start. > > That sort of thing really isn't helpful.dunno, it worked for me. I'll review and try to find out what you're seeing. /dale --- >8 ---- List archives: http://www.xiph.org/archives/ icecast project homepage: http://www.icecast.org/ To unsubscribe from this list, send a message to 'icecast-dev-request@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.
Michael Smith
2004-Aug-06  14:57 UTC
[icecast-dev] [PATCH] main.c: use pid_t and cleanup command line opts parsing.
On Sunday 21 March 2004 07:32, Dale Ghent wrote:> Use pid_t instead of int for variable processID > > Add error message if fork() fails. > > Do not immediately return() after encountering the -c flag - we may still > have additional argv members to find and take care of. >Obviously not even tested; it is clear that with this patch icecast will always refuse to start. That sort of thing really isn't helpful. Mike <p>--- >8 ---- List archives: http://www.xiph.org/archives/ icecast project homepage: http://www.icecast.org/ To unsubscribe from this list, send a message to 'icecast-dev-request@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.