Author: dnusinow Date: 2005-07-03 12:17:02 -0500 (Sun, 03 Jul 2005) New Revision: 304
Added: trunk/debian/patches/099x_xdm_support_logfile_rotation.diff Modified: trunk/debian/TODO Log: - Patch audit. - Port 099x_xdm_support_logfile_rotation.diff from xfree86 trunk. Modified: trunk/debian/TODO =================================================================== --- trunk/debian/TODO 2005-07-02 22:04:29 UTC (rev 303) +++ trunk/debian/TODO 2005-07-03 17:17:02 UTC (rev 304) @@ -23,7 +23,6 @@ Have to see whether it's still needed for GNU/kFreeBSD, and if so, fix the bug. See Freedesktop Bugzilla #1902. 099u_mkdirhier_rewrite.diff -- needs porting -099x_xdm_support_logfile_rotation.diff -- needs porting 099z_xkb_level3_ralt_switch.diff -- present under same name, but without changes to: (Why?) xc/programs/xkbcomp/symbols/pc/dvorak Added: trunk/debian/patches/099x_xdm_support_logfile_rotation.diff =================================================================== --- trunk/debian/patches/099x_xdm_support_logfile_rotation.diff 2005-07-02 22:04:29 UTC (rev 303) +++ trunk/debian/patches/099x_xdm_support_logfile_rotation.diff 2005-07-03 17:17:02 UTC (rev 304) @@ -0,0 +1,171 @@ +$Id$ + +Implement new ReopenLogFile() and ReopenLogFileNotify() functions to +facilitate log rotation. ReopenLogFileNotify() is a signal handler for +SIGUSR2. See Debian #303688. + +Move the definition of the WRITES() macro from error.c to dm_error.h so +that dm.c can use it as well. + +This patch by Branden Robinson. + +Not submitted upstream to X.Org. + +diff -ruN xc-old/programs/xdm/dm.c xc/programs/xdm/dm.c +--- xc-old/programs/xdm/dm.c 2005-07-02 18:47:33.000000000 -0400 ++++ xc/programs/xdm/dm.c 2005-07-02 19:00:28.000000000 -0400 +@@ -78,8 +78,10 @@ + extern FILE *fdopen(); + #endif + +-static SIGVAL StopAll (int n), RescanNotify (int n); ++static SIGVAL StopAll (int n), RescanNotify (int n), ++ ReopenLogFileNotify (int n); + static void RescanServers (void); ++static void ReopenLogFile (void); + static void RestartDisplay (struct display *d, int forceReserver); + static void ScanServers (void); + static void SetAccessFileTime (void); +@@ -88,6 +90,7 @@ + static void TerminateProcess (int pid, int signal); + + volatile int Rescan; ++volatile int Reopen; + static long ServersModTime, ConfigModTime, AccessFileModTime; + + int nofork_session = 0; +@@ -199,6 +202,7 @@ + AddOtherEntropy(); + #endif + (void) Signal (SIGHUP, RescanNotify); ++ (void) Signal (SIGUSR2, ReopenLogFileNotify); + #ifndef UNRELIABLE_SIGNALS + (void) Signal (SIGCHLD, ChildNotify); + #endif +@@ -209,6 +213,11 @@ + #endif + AnyDisplaysLeft ()) + { ++ if (Reopen) ++ { ++ ReopenLogFile (); ++ Reopen = 0; ++ } + if (Rescan) + { + RescanServers (); +@@ -233,6 +242,7 @@ + int olderrno = errno; + + Debug ("caught SIGHUP\n"); ++ Reopen = 1; + Rescan = 1; + #ifdef SIGNALS_RESET_WHEN_CAUGHT + (void) Signal (SIGHUP, RescanNotify); +@@ -240,6 +250,26 @@ + errno = olderrno; + } + ++/* ++ * Handle a SIGUSR2: set variable that will instruct the main loop to ++ * reopen the log file. ++ */ ++static void ++ReopenLogFileNotify (int n) ++{ ++#ifdef SIGNALS_RESET_WHEN_CAUGHT ++ int olderrno = errno; ++#endif ++ ++ /* Debug() is not safe inside a signal handler. */ ++ WRITES(STDERR_FILENO, "ReopenLogFileNotify handling SIGUSR2\n"); ++ Reopen = 1; ++#ifdef SIGNALS_RESET_WHEN_CAUGHT ++ (void) Signal (SIGUSR2, ReopenLogFileNotify); ++ errno = olderrno; ++#endif ++} ++ + static void + ScanServers (void) + { +@@ -307,6 +337,14 @@ + } + + static void ++ReopenLogFile (void) ++{ ++ Debug ("closing standard error file descriptor %d\n", STDERR_FILENO); ++ close (STDERR_FILENO); ++ InitErrorLog (); ++} ++ ++static void + SetConfigFileTime (void) + { + struct stat statb; +diff -ruN xc-old/programs/xdm/dm_error.h xc/programs/xdm/dm_error.h +--- xc-old/programs/xdm/dm_error.h 2005-07-02 18:47:33.000000000 -0400 ++++ xc/programs/xdm/dm_error.h 2005-07-02 19:00:55.000000000 -0400 +@@ -44,6 +44,8 @@ + # define GCC_PRINTFLIKE(fmt,var) /*nothing*/ + #endif + ++#define WRITES(fd, buf) write(fd, buf, strlen(buf)) ++ + extern void Debug (char * fmt, ...) GCC_PRINTFLIKE(1,2); + extern void InitErrorLog (void); + extern void LogError (char * fmt, ...) GCC_PRINTFLIKE(1,2); +diff -ruN xc-old/programs/xdm/error.c xc/programs/xdm/error.c +--- xc-old/programs/xdm/error.c 2005-07-02 18:47:33.000000000 -0400 ++++ xc/programs/xdm/error.c 2005-07-02 19:01:10.000000000 -0400 +@@ -49,8 +49,6 @@ + #include "dm.h" + #include "dm_error.h" + +-#define WRITES(fd, buf) write(fd, buf, strlen(buf)) +- + void + LogInfo(char * fmt, ...) + { +diff -ruN xc-old/programs/xdm/xdm.man xc/programs/xdm/xdm.man +--- xc-old/programs/xdm/xdm.man 2005-07-02 18:47:33.000000000 -0400 ++++ xc/programs/xdm/xdm.man 2005-07-02 19:02:53.000000000 -0400 +@@ -1348,6 +1348,37 @@ + multiple window systems on the same hardware, you'll probably be more + interested in + .I xinit. ++.SH "ASYNCHRONOUS EVENTS" ++.B xdm ++uses ++.B SIGALRM ++and ++.B SIGUSR1 ++for its own inter-process communication purposes, managing the relationship ++between the parent ++.B xdm ++process and its children. ++Sending these signals to any ++.B xdm ++process may result in unexpected behavior. ++.TP ++.B SIGHUP ++causes ++.B xdm ++to rescan its configuration files and reopen its log file. ++.TP ++.B SIGTERM ++causes ++.B xdm ++to terminate its children and shut down. ++.TP ++.B SIGUSR2 ++causes ++.B xdm ++to reopen its log file. ++This is useful if log rotation is desired, but ++.B SIGHUP ++is too disruptive. + .SH FILES + .TP 20 + .I __projectroot__/lib/X11/xdm/xdm-config -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]