[PATCH 03/10] Add timestamping to logging functions

Alan Coopersmith Alan.Coopersmith at Sun.COM
Tue Jan 5 13:16:19 PST 2010

Alan Coopersmith wrote:
> strftime isn't signal safe, but I see some of the signal handlers log.

BTW, just like when this issue came up with the similar proposed patch to
Xorg, I do like the idea of timestamps, and solving it in xdm should be
easier than Xorg since there's only one source tree, with no external
loadable modules to worry about.

Options I see for doing it safely:
 - remove log function calls from anything called from a signal handler
 - provide signal handler variants of the log functions that don't use
   strftime() and make sure you only call those from the handlers
 - have a volatile global variable that's set on signal handler entry
   that disables timestamps and is cleared on signal handler exit - saves
   having to track down every code path or have functions lose timestamps
   or log output when not called from signal handlers.

Of course, if you do allow logging from signal handlers, it can get messy
if you interrupt a logging function call with a signal handler that logs,
since the log functions make multiple calls to write the header, then the
body, but that's cosmetic, not the possibility of deadlock or segfault.

	-Alan Coopersmith-           alan.coopersmith at sun.com
	 Sun Microsystems, Inc. - X Window System Engineering

More information about the xorg-devel mailing list