summaryrefslogtreecommitdiff
path: root/os/log.c
diff options
context:
space:
mode:
authorChase Douglas <chase.douglas@canonical.com>2012-04-06 08:03:09 -0700
committerPeter Hutterer <peter.hutterer@who-t.net>2012-06-21 15:45:22 +1000
commitbc85c81687a24aea738094ff11f4448fb3b3afbb (patch)
treefc15535b346071cfa414059d8720b6ef5bac7182 /os/log.c
parentd3725549f0276487fba1d419094209d18e86669f (diff)
Save log file file descriptor for signal context logging
None of the FILE based functions are signal safe, including fileno(), so we need to save the file descriptor for when we are in signal context. Signed-off-by: Chase Douglas <chase.douglas@canonical.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'os/log.c')
-rw-r--r--os/log.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/os/log.c b/os/log.c
index 2c13c1a7d..5394847aa 100644
--- a/os/log.c
+++ b/os/log.c
@@ -108,6 +108,7 @@ void (*OsVendorVErrorFProc) (const char *, va_list args) = NULL;
#endif
static FILE *logFile = NULL;
+static int logFileFd = -1;
static Bool logFlush = FALSE;
static Bool logSync = FALSE;
static int logVerbosity = DEFAULT_LOG_VERBOSITY;
@@ -211,6 +212,8 @@ LogInit(const char *fname, const char *backup)
FatalError("Cannot open log file \"%s\"\n", logFileName);
setvbuf(logFile, NULL, _IONBF, 0);
+ logFileFd = fileno(logFile);
+
/* Flush saved log information. */
if (saveBuffer && bufferSize > 0) {
fwrite(saveBuffer, bufferPos, 1, logFile);
@@ -243,6 +246,7 @@ LogClose(enum ExitCode error)
(error == EXIT_NO_ERROR) ? "successfully" : "with error", error);
fclose(logFile);
logFile = NULL;
+ logFileFd = -1;
}
}