]> git.webhop.me Git - lcd4linux.git/commitdiff
[lcd4linux @ 2003-08-08 06:58:06 by reinelt]
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Fri, 8 Aug 2003 06:58:06 +0000 (06:58 +0000)
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Fri, 8 Aug 2003 06:58:06 +0000 (06:58 +0000)
improved forking

git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@207 3ae390bd-cb1e-0410-b409-cd5a39f66f1f

ChangeLog
configure
debug.c
lcd4linux.c

index 86896ea65130ab32174648ab37d2c7142954ea55..7ba02a7bce8223470c80b0c4ecce6bfb609ef42e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2003-08-08  Michael Reinelt  <reinelt@lizard.reinelt>
+
+       * ChangeLog, TODO, config.h.in, configure, configure.in, dvb.c, CREDITS:
+       uClibc compatibility issue; small glitch in dvb.c
+
 2003-08-01  Michael Reinelt  <reinelt@lizard.reinelt>
 
        * Cwlinux.c, Makefile.am, Makefile.in, README, T6963.c:
index 6006f45b508e7beeed48422402e3a39053872c5f..ffc6214633a1bd8e3889ef8d891fa63b84228c9d 100755 (executable)
--- a/configure
+++ b/configure
@@ -1135,7 +1135,7 @@ _ASBOX
       echo "$as_me: caught signal $ac_signal"
     echo "$as_me: exit $exit_status"
   } >&5
-  rm -f core core.* *.core &&
+  rm -f core *.core &&
   rm -rf conftest* confdefs* conf$$* $ac_clean_files &&
     exit $exit_status
      ' 0
@@ -4619,7 +4619,7 @@ sed 's/^/| /' conftest.$ac_ext >&5
 ( exit $ac_status )
 ac_cv_header_stdc=no
 fi
-rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
 fi
 fi
@@ -5273,7 +5273,7 @@ sed 's/^/| /' conftest.$ac_ext >&5
 ( exit $ac_status )
 ac_cv_header_stdc=no
 fi
-rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
 fi
 fi
@@ -6903,7 +6903,7 @@ sed 's/^/| /' conftest.$ac_ext >&5
 ( exit $ac_status )
 ac_cv_func_fork_works=no
 fi
-rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
 fi
 echo "$as_me:$LINENO: result: $ac_cv_func_fork_works" >&5
@@ -7058,7 +7058,7 @@ sed 's/^/| /' conftest.$ac_ext >&5
 ( exit $ac_status )
 ac_cv_func_vfork_works=no
 fi
-rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
 fi
 echo "$as_me:$LINENO: result: $ac_cv_func_vfork_works" >&5
@@ -7144,7 +7144,7 @@ echo "${ECHO_T}$ac_cv_prog_gcc_traditional" >&6
   fi
 fi
 
-#removed for ulibc compatibility
+#removed for uClibc compatibility
 #AC_FUNC_MALLOC
 echo "$as_me:$LINENO: checking for working memcmp" >&5
 echo $ECHO_N "checking for working memcmp... $ECHO_C" >&6
@@ -7214,7 +7214,7 @@ sed 's/^/| /' conftest.$ac_ext >&5
 ( exit $ac_status )
 ac_cv_func_memcmp_working=no
 fi
-rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
 fi
 echo "$as_me:$LINENO: result: $ac_cv_func_memcmp_working" >&5
@@ -7412,7 +7412,7 @@ sed 's/^/| /' conftest.$ac_ext >&5
 ( exit $ac_status )
 ac_cv_func_realloc_0_nonnull=no
 fi
-rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
 fi
 echo "$as_me:$LINENO: result: $ac_cv_func_realloc_0_nonnull" >&5
@@ -7774,7 +7774,7 @@ sed 's/^/| /' conftest.$ac_ext >&5
 ( exit $ac_status )
 ac_cv_func_lstat_dereferences_slashed_symlink=no
 fi
-rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
 else
   # If the `ln -s' command failed, then we probably don't even
@@ -7843,7 +7843,7 @@ sed 's/^/| /' conftest.$ac_ext >&5
 ( exit $ac_status )
 ac_cv_func_stat_empty_string_bug=no
 fi
-rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
 fi
 echo "$as_me:$LINENO: result: $ac_cv_func_stat_empty_string_bug" >&5
diff --git a/debug.c b/debug.c
index 271ad9f9c8e03bec6ce16b051fdfceeedb6902e2..a90fec7dd03427cb1337e8022512d0ce15e68389 100644 (file)
--- a/debug.c
+++ b/debug.c
@@ -1,4 +1,4 @@
-/* $Id: debug.c,v 1.3 2001/03/12 12:39:36 reinelt Exp $
+/* $Id: debug.c,v 1.4 2003/08/08 06:58:06 reinelt Exp $
  *
  * debug() and error() functions
  *
@@ -20,6 +20,9 @@
  *
  *
  * $Log: debug.c,v $
+ * Revision 1.4  2003/08/08 06:58:06  reinelt
+ * improved forking
+ *
  * Revision 1.3  2001/03/12 12:39:36  reinelt
  *
  * reworked autoconf a lot: drivers may be excluded, #define's went to config.h
@@ -62,6 +65,7 @@ void message (int level, const char *format, ...)
   static int log_open=0;
   extern int debugging;
   extern int foreground;
+  extern int background;
 
   if (level>debugging) return;
 
@@ -69,15 +73,17 @@ void message (int level, const char *format, ...)
   (void) vsnprintf(buffer, sizeof(buffer), format, ap);
   va_end(ap);
   
-  if (foreground) {
+  if (!background) {
 #ifdef WITH_TEXT
     extern int curs_err(char *);
     if (!curs_err(buffer))
 #endif      
-    fprintf (level?stdout:stderr, "%s\n", buffer);
-    return;
+      fprintf (level?stdout:stderr, "%s\n", buffer);
   }
-
+  
+  if (foreground)
+    return;
+  
   if (!log_open) {
     openlog ("LCD4Linux", LOG_PID, LOG_USER);
     log_open=1;
index dee44fda1e24c5745a170b4ac3ff94c5cf1537f2..9a1e64b632cdec1c1f3486595c99768a182ff532 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: lcd4linux.c,v 1.39 2003/07/24 04:48:09 reinelt Exp $
+/* $Id: lcd4linux.c,v 1.40 2003/08/08 06:58:06 reinelt Exp $
  *
  * LCD4Linux
  *
@@ -20,6 +20,9 @@
  *
  *
  * $Log: lcd4linux.c,v $
+ * Revision 1.40  2003/08/08 06:58:06  reinelt
+ * improved forking
+ *
  * Revision 1.39  2003/07/24 04:48:09  reinelt
  * 'soft clear' needed for virtual rows
  *
@@ -224,6 +227,7 @@ char *output=NULL;
 int got_signal=0;
 int debugging=0;
 int foreground=0;
+int background=0;
 int tick, tack;
 
 static void usage(void)
@@ -363,6 +367,26 @@ int main (int argc, char *argv[])
     exit(2);
   }
 
+  info ("Version " VERSION " starting");
+  if (!foreground && (my_argv[0]==NULL || my_argv[0][0]!='/')) {
+    info ("invoked without full path; restart may not work!");
+  }
+  
+  // set default values
+  cfg_set ("row1", "*** %o %v ***");
+  cfg_set ("row2", "%p CPU  %r MB RAM");
+  cfg_set ("row3", "Busy %cu%% $r10cu");
+  cfg_set ("row4", "Load %l1%L$r10l1");
+
+  if (cfg_read (cfg)==-1)
+    exit (1);
+  
+  driver=cfg_get("display",NULL);
+  if (driver==NULL || *driver=='\0') {
+    error ("missing 'display' entry in %s!", cfg_file());
+    exit (1);
+  }
+  
   if (!foreground) {
     pid_t i;
     int fd;
@@ -377,11 +401,22 @@ int main (int argc, char *argv[])
     // ignore nasty signals
     signal(SIGINT,  SIG_IGN);
     signal(SIGQUIT, SIG_IGN);
+
+    // chdir("/")
+    if (chdir("/")!=0) {
+      error ("chdir(\"/\") failed: %s", strerror(errno));
+      exit (1);
+    }
+    
+    // we want full control over permissions
+    umask (0);
+    
     // detach stdin
     if (freopen("/dev/null", "r", stdin)==NULL) {
       error ("freopen (/dev/null) failed: %s", strerror(errno));
       exit (1);
     }
+
     // detach stdout and stderr
     fd=open("/dev/null", O_WRONLY, 0666);
     if (fd==-1) {
@@ -393,30 +428,7 @@ int main (int argc, char *argv[])
     dup2(fd, STDOUT_FILENO);
     dup2(fd, STDERR_FILENO);
     close(fd);
-  }
-  
-  if (foreground) {
-    info ("Version " VERSION " starting");
-  } else {
-    info ("Version " VERSION " starting");
-    if (my_argv[0]==NULL || my_argv[0][0]!='/') {
-      info ("invoked without full path; restart may not work!");
-    }
-  }
-  
-  // set default values
-  cfg_set ("row1", "*** %o %v ***");
-  cfg_set ("row2", "%p CPU  %r MB RAM");
-  cfg_set ("row3", "Busy %cu%% $r10cu");
-  cfg_set ("row4", "Load %l1%L$r10l1");
-
-  if (cfg_read (cfg)==-1)
-    exit (1);
-  
-  driver=cfg_get("display",NULL);
-  if (driver==NULL || *driver=='\0') {
-    error ("missing 'display' entry in %s!", cfg_file());
-    exit (1);
+    background=1;
   }
   
   debug ("initializing driver %s", driver);