freebsd-ports/x11/kdebase4/files/patch-error.c
Will Andrews d1c2f0dddd Please welcome Qt3/KDE3 to our ports tree. This includes work since the
original versions of these ports, so some PORTREVISIONs were bumped.  See
http://freebsd.kde.org/ and mailing lists linked to from there for info
on the packages generated to test these ports.

bsd.kde.mk has already been updated a few days ago to work with these.

Some patches applied to fix a few bugs were:

deskutils/kdepim3:
        [1] Remove kpilot from build because it wasn't ready at release.
editors/koffice-kde3:
        [2] Fix compile time bugs for FreeBSD.
misc/kdeedu3:
        [3] Fix compile problem with kvoctrain.
x11/kdebase3:
        [4] Fix KDM CPU usage and login bug.

Some caveats:
        * All PLISTs are broken for deinstall due to script bug that I
          didn't notice until very recently.  This will be fixed when I
          commit an update tomorrow.  These ports should still install
          perfectly fine though.  They should also deinstall without
          giving errors, but will leave directories behind.
        * You can't install this with any other version of QT or KDE
          already installed.  I am not sure the checks are 100% working,
          but fixes for these will be forthcoming.  This is mainly due
          to a policy decision made by kde@ to make QT/KDE ports install
          the way the rest of the world expects it to while also still
          conforming to FreeBSD's hier(7).  For reference on this decision,
          please consult the KDE/FreeBSD mailing list archives.  This
          decision fixes 2-year-old bug reports relating to how we handled
          this for KDE2 vs KDE1.

Submitted by:   [1] Adrian de Groot <adridg@cs.kun.nl>,
                [2] David Faure <faure@kde.org>,
                    Andy Fawcett <andy@athame.co.uk>
                    Lauri Watts <lauri@kde.org>
                [3] Lauri Watts <lauri@kde.org>
                [4] Alan Eldridge <alane@geeksrus.net>
                    Oswald Buddenhagen <ossi@kde.org>
Reviewed by:    kde
2002-04-21 23:47:50 +00:00

60 lines
1.3 KiB
C

--- ./kdm/backend/error.c.orig Sun Mar 24 12:31:09 2002
+++ ./kdm/backend/error.c Thu Apr 18 20:53:44 2002
@@ -43,6 +43,8 @@
#include "dm.h"
#include "dm_error.h"
+#include <sys/stat.h>
+#include <unistd.h>
#include <stdio.h>
#define PRINT_QUOTES
@@ -91,6 +93,10 @@
void
InitErrorLog (const char *errorLogFile)
{
+ int fd;
+ struct stat st;
+ char buf[128];
+
#ifdef USE_SYSLOG
# ifdef USE_PAM
ReInitErrorLog ();
@@ -101,15 +107,33 @@
/* We do this independently of using syslog, as we cannot redirect
* the output of external programs to syslog.
*/
- if (isatty (2)) {
- char buf[100];
+ if (errorLogFile
+ || fstat (1, &st) ||
+#ifndef X_NOT_POSIX
+ !(S_ISREG(st.st_mode) || S_ISFIFO(st.st_mode))
+#else
+ !(st.st_mode & (S_IFREG | S_IFIFO))
+#endif
+ || fstat (2, &st) ||
+#ifndef X_NOT_POSIX
+ !(S_ISREG(st.st_mode) || S_ISFIFO(st.st_mode)))
+#else
+ !(st.st_mode & (S_IFREG | S_IFIFO)))
+#endif
+ {
if (!errorLogFile) {
sprintf (buf, "/var/log/%s.log", prog);
errorLogFile = buf;
}
- if (!freopen (errorLogFile, "a", stderr))
+ if ((fd = open (errorLogFile, O_CREAT | O_APPEND | O_WRONLY, 0666)) < 0)
LogError ("Cannot open log file %s\n", errorLogFile);
+ else {
+ if (fd != 1) {
+ dup2 (fd, 1);
+ close (fd);
+ }
+ dup2 (1, 2);
+ }
}
- dup2 (2, 1);
}