diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2009-10-10 10:12:50 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2009-10-10 10:12:50 +0000 |
commit | b1f67da8b1b0cc93ea54a5c4ae89e6e835657729 (patch) | |
tree | 58a5112492c1b23d03a7bf341d52de37330c9883 /app/xfs/os/error.c | |
parent | ffd564eb05c09caff0dba3c4eb783739645a440e (diff) |
update to xfs 1.1.0.
Diffstat (limited to 'app/xfs/os/error.c')
-rw-r--r-- | app/xfs/os/error.c | 51 |
1 files changed, 22 insertions, 29 deletions
diff --git a/app/xfs/os/error.c b/app/xfs/os/error.c index 8c72a657c..d078f640c 100644 --- a/app/xfs/os/error.c +++ b/app/xfs/os/error.c @@ -1,4 +1,3 @@ -/* $Xorg: error.c,v 1.4 2001/02/09 02:05:44 xorgcvs Exp $ */ /* * error message handling */ @@ -44,33 +43,14 @@ in this Software without prior written authorization from The Open Group. * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF * THIS SOFTWARE. */ -/* $XFree86: error.c,v 1.11 2002/10/15 01:45:03 dawes Exp $ */ + +#include "xfs-config.h" #include <stdio.h> #include <stdlib.h> #include <stdarg.h> #include <X11/Xos.h> -#ifndef X_NOT_POSIX -#ifdef _POSIX_SOURCE -#include <limits.h> -#else -#define _POSIX_SOURCE -#include <limits.h> -#undef _POSIX_SOURCE -#endif -#endif -#ifndef PATH_MAX -#include <sys/param.h> -#ifndef PATH_MAX -#ifdef MAXPATHLEN -#define PATH_MAX MAXPATHLEN -#else -#define PATH_MAX 1024 -#endif -#endif -#endif - #ifdef USE_SYSLOG #include <syslog.h> #endif @@ -78,13 +58,11 @@ in this Software without prior written authorization from The Open Group. #include <errno.h> #include "misc.h" - -extern char *progname; +#include "globals.h" +#include "osdep.h" Bool UseSyslog; -#ifdef USE_SYSLOG Bool log_open = FALSE; -#endif char ErrorFile[PATH_MAX]; static char CurrentErrorFile[PATH_MAX]; @@ -113,11 +91,13 @@ InitErrors(void) } #endif - if (ErrorFile[0] && strcmp(CurrentErrorFile, ErrorFile) != 0) { - i = creat(ErrorFile, 0666); + if (ErrorFile[0] && + (!log_open || (strcmp(CurrentErrorFile, ErrorFile) != 0)) ) { + i = open(ErrorFile, O_WRONLY | O_APPEND | O_CREAT, 0666); if (i != -1) { dup2(i, 2); close(i); + log_open = TRUE; } else { ErrorF("can't open error file \"%s\"\n", ErrorFile); } @@ -128,13 +108,26 @@ InitErrors(void) void CloseErrors(void) { + int nullfd; + + if (!log_open) + return; + + log_open = FALSE; + #ifdef USE_SYSLOG if (UseSyslog) { closelog(); - log_open = FALSE; return; } #endif + + close (2); + nullfd = open ("/dev/null", O_RDWR); + if (nullfd != 2) { + dup2 (nullfd, 2); + close(nullfd); + } } void |