From 1934af04c445632c42de495e0ccdcb01e1b06c6e Mon Sep 17 00:00:00 2001 From: reinelt Date: Fri, 8 Aug 2003 06:58:06 +0000 Subject: [lcd4linux @ 2003-08-08 06:58:06 by reinelt] improved forking git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@207 3ae390bd-cb1e-0410-b409-cd5a39f66f1f --- ChangeLog | 5 +++++ configure | 20 ++++++++++---------- debug.c | 16 +++++++++++----- lcd4linux.c | 62 ++++++++++++++++++++++++++++++++++++------------------------- 4 files changed, 63 insertions(+), 40 deletions(-) diff --git a/ChangeLog b/ChangeLog index 86896ea..7ba02a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2003-08-08 Michael 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 * Cwlinux.c, Makefile.am, Makefile.in, README, T6963.c: diff --git a/configure b/configure index 6006f45..ffc6214 100755 --- 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 271ad9f..a90fec7 100644 --- 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; diff --git a/lcd4linux.c b/lcd4linux.c index dee44fd..9a1e64b 100644 --- a/lcd4linux.c +++ b/lcd4linux.c @@ -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); -- cgit v1.2.3