[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
This commit is contained in:
reinelt
2003-08-08 06:58:06 +00:00
parent 0184cfba3e
commit 1934af04c4
4 changed files with 78 additions and 55 deletions
+5
View File
@@ -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:
Vendored
+10 -10
View File
@@ -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
+11 -5
View File
@@ -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;
+52 -40
View 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,45 +367,9 @@ int main (int argc, char *argv[])
exit(2);
}
if (!foreground) {
pid_t i;
int fd;
debug ("going background...");
i=fork();
if (i<0) {
error ("fork() failed: %s", strerror(errno));
exit (1);
}
if (i!=0) exit (0);
// ignore nasty signals
signal(SIGINT, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
// 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) {
error ("open (/dev/null) failed: %s", strerror(errno));
exit (1);
}
fflush(stdout);
fflush(stderr);
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!");
}
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
@@ -419,6 +387,50 @@ int main (int argc, char *argv[])
exit (1);
}
if (!foreground) {
pid_t i;
int fd;
debug ("going background...");
i=fork();
if (i<0) {
error ("fork() failed: %s", strerror(errno));
exit (1);
}
if (i!=0) exit (0);
// 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) {
error ("open (/dev/null) failed: %s", strerror(errno));
exit (1);
}
fflush(stdout);
fflush(stderr);
dup2(fd, STDOUT_FILENO);
dup2(fd, STDERR_FILENO);
close(fd);
background=1;
}
debug ("initializing driver %s", driver);
if (lcd_init(driver)==-1) {
exit (1);