156 lines
5.0 KiB
Diff
156 lines
5.0 KiB
Diff
|
--- src/lib/report-lib.c
|
||
|
+++ src/lib/report-lib.c
|
||
|
@@ -41,5 +41,7 @@
|
||
|
vfprintf(stderr,text,ap);
|
||
|
fprintf(stderr,"\n");
|
||
|
|
||
|
+ va_end(ap);
|
||
|
+
|
||
|
if(stat == GPM_STAT_OOPS) exit(1); /* may a lib function call exit ???? */
|
||
|
}
|
||
|
--- src/report.c
|
||
|
+++ src/report.c
|
||
|
@@ -71,9 +71,18 @@
|
||
|
void gpm_report(int line, char *file, int stat, char *text, ... )
|
||
|
{
|
||
|
FILE *console = NULL;
|
||
|
- va_list ap;
|
||
|
+ va_list ap,ap2;
|
||
|
+#ifdef HAVE_VSYSLOG
|
||
|
+ va_list ap_sys;
|
||
|
+#endif
|
||
|
+ int exit_request=0; /* 0 -> return is requested
|
||
|
+ 1 -> exit(1) is requested
|
||
|
+ 2 -> _exit(1) is requested */
|
||
|
|
||
|
va_start(ap,text);
|
||
|
+#ifdef HAVE_VSYSLOG
|
||
|
+ va_copy(ap_sys,ap);
|
||
|
+#endif
|
||
|
|
||
|
switch(option.run_status) {
|
||
|
/******************** STARTUP *****************/
|
||
|
@@ -82,7 +91,7 @@
|
||
|
case GPM_STAT_INFO:
|
||
|
#ifdef HAVE_VSYSLOG
|
||
|
syslog(LOG_INFO | LOG_USER, GPM_STRING_INFO);
|
||
|
- vsyslog(LOG_INFO | LOG_USER, text, ap);
|
||
|
+ vsyslog(LOG_INFO | LOG_USER, text, ap_sys);
|
||
|
#endif
|
||
|
fprintf(stderr,GPM_STRING_INFO);
|
||
|
vfprintf(stderr,text,ap);
|
||
|
@@ -92,7 +101,7 @@
|
||
|
case GPM_STAT_WARN:
|
||
|
#ifdef HAVE_VSYSLOG
|
||
|
syslog(LOG_DAEMON | LOG_WARNING, GPM_STRING_WARN);
|
||
|
- vsyslog(LOG_DAEMON | LOG_WARNING, text, ap);
|
||
|
+ vsyslog(LOG_DAEMON | LOG_WARNING, text, ap_sys);
|
||
|
#endif
|
||
|
fprintf(stderr,GPM_STRING_WARN);
|
||
|
vfprintf(stderr,text,ap);
|
||
|
@@ -102,7 +111,7 @@
|
||
|
case GPM_STAT_ERR:
|
||
|
#ifdef HAVE_VSYSLOG
|
||
|
syslog(LOG_DAEMON | LOG_ERR, GPM_STRING_ERR);
|
||
|
- vsyslog(LOG_DAEMON | LOG_ERR, text, ap);
|
||
|
+ vsyslog(LOG_DAEMON | LOG_ERR, text, ap_sys);
|
||
|
#endif
|
||
|
fprintf(stderr,GPM_STRING_ERR);
|
||
|
vfprintf(stderr,text,ap);
|
||
|
@@ -112,13 +121,13 @@
|
||
|
case GPM_STAT_OOPS:
|
||
|
#ifdef HAVE_VSYSLOG
|
||
|
syslog(LOG_DAEMON | LOG_ERR, GPM_STRING_OOPS);
|
||
|
- vsyslog(LOG_DAEMON | LOG_ERR, text, ap);
|
||
|
+ vsyslog(LOG_DAEMON | LOG_ERR, text, ap_sys);
|
||
|
#endif
|
||
|
fprintf(stderr,GPM_STRING_OOPS);
|
||
|
vfprintf(stderr,text,ap);
|
||
|
fprintf(stderr,"\n");
|
||
|
|
||
|
- exit(1); /* we should have a oops()-function,but this works,too*/
|
||
|
+ exit_request=1; /* we should have a oops()-function,but this works,too*/
|
||
|
break;
|
||
|
}
|
||
|
break; /* startup sequence */
|
||
|
@@ -129,14 +138,14 @@
|
||
|
case GPM_STAT_INFO:
|
||
|
#ifdef HAVE_VSYSLOG
|
||
|
syslog(LOG_INFO | LOG_USER, GPM_STRING_INFO);
|
||
|
- vsyslog(LOG_INFO | LOG_USER, text, ap);
|
||
|
+ vsyslog(LOG_INFO | LOG_USER, text, ap_sys);
|
||
|
#endif
|
||
|
break;
|
||
|
|
||
|
case GPM_STAT_WARN:
|
||
|
#ifdef HAVE_VSYSLOG
|
||
|
syslog(LOG_DAEMON | LOG_WARNING, GPM_STRING_WARN);
|
||
|
- vsyslog(LOG_DAEMON | LOG_WARNING, text, ap);
|
||
|
+ vsyslog(LOG_DAEMON | LOG_WARNING, text, ap_sys);
|
||
|
#endif
|
||
|
if((console = fopen(GPM_SYS_CONSOLE,"a")) != NULL) {
|
||
|
fprintf(console,GPM_STRING_WARN);
|
||
|
@@ -149,8 +158,9 @@
|
||
|
case GPM_STAT_ERR:
|
||
|
#ifdef HAVE_VSYSLOG
|
||
|
syslog(LOG_DAEMON | LOG_ERR, GPM_STRING_ERR);
|
||
|
- vsyslog(LOG_DAEMON | LOG_ERR, text, ap);
|
||
|
+ vsyslog(LOG_DAEMON | LOG_ERR, text, ap_sys);
|
||
|
#endif
|
||
|
+ va_copy(ap2,ap);
|
||
|
if((console = fopen(GPM_SYS_CONSOLE,"a")) != NULL) {
|
||
|
fprintf(console,GPM_STRING_ERR);
|
||
|
vfprintf(console,text,ap);
|
||
|
@@ -160,22 +170,24 @@
|
||
|
|
||
|
if((console = fopen(option.consolename,"a")) != NULL) {
|
||
|
fprintf(console,GPM_STRING_ERR);
|
||
|
- vfprintf(console,text,ap);
|
||
|
+ vfprintf(console,text,ap2);
|
||
|
fprintf(console,"\n");
|
||
|
fclose(console);
|
||
|
}
|
||
|
+
|
||
|
+ va_end(ap2);
|
||
|
break;
|
||
|
|
||
|
case GPM_STAT_OOPS:
|
||
|
#ifdef HAVE_VSYSLOG
|
||
|
syslog(LOG_DAEMON | LOG_ERR, GPM_STRING_OOPS);
|
||
|
- vsyslog(LOG_DAEMON | LOG_ERR, text, ap);
|
||
|
+ vsyslog(LOG_DAEMON | LOG_ERR, text, ap_sys);
|
||
|
#endif
|
||
|
fprintf(stderr,GPM_STRING_OOPS);
|
||
|
vfprintf(stderr,text,ap);
|
||
|
fprintf(stderr,"\n");
|
||
|
|
||
|
- _exit(1); /* we are the fork()-child */
|
||
|
+ exit_request=2; /* we are the fork()-child */
|
||
|
break;
|
||
|
}
|
||
|
break; /* running gpm */
|
||
|
@@ -203,10 +215,21 @@
|
||
|
vfprintf(console,text,ap);
|
||
|
fprintf(console,"\n");
|
||
|
|
||
|
- if(stat == GPM_STAT_OOPS) exit(1);
|
||
|
-
|
||
|
+ if(stat == GPM_STAT_OOPS) exit_request=1;
|
||
|
+
|
||
|
break;
|
||
|
} /* switch for current modus */
|
||
|
+
|
||
|
+ va_end(ap);
|
||
|
+#ifdef HAVE_VSYSLOG
|
||
|
+ va_end(ap_sys);
|
||
|
+#endif
|
||
|
+
|
||
|
+ if (exit_request == 2)
|
||
|
+ _exit(1);
|
||
|
+ if (exit_request == 1)
|
||
|
+ exit(1);
|
||
|
+ return;
|
||
|
} /* gpm_report */
|
||
|
|
||
|
|