Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Unified Diff: base/logging.cc

Issue 115773: Prototype implementation of zygotes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/logging.h ('k') | base/process_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/logging.cc
===================================================================
--- base/logging.cc (revision 17632)
+++ base/logging.cc (working copy)
@@ -19,9 +19,12 @@
#endif
#if defined(OS_POSIX)
+#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include <unistd.h>
#define MAX_PATH PATH_MAX
typedef FILE* FileHandle;
@@ -37,6 +40,7 @@
#include "base/command_line.h"
#include "base/debug_util.h"
#include "base/lock_impl.h"
+#include "base/reserved_file_descriptors.h"
#include "base/string_piece.h"
#include "base/string_util.h"
#include "base/sys_string_conversions.h"
@@ -205,7 +209,17 @@
}
SetFilePointer(log_file, 0, 0, FILE_END);
#elif defined(OS_POSIX)
+ // Reserve global fd slots.
+ int reserved_fds[kReservedFds];
+ for (int i=0; i < kReservedFds; i++)
+ reserved_fds[i] = open("/dev/null", O_RDONLY, 0);
+
log_file = fopen(log_file_name->c_str(), "a");
+
+ // Release the reserved fds.
+ for (int i=0; i < kReservedFds; i++)
+ close(reserved_fds[i]);
+
if (log_file == NULL)
return false;
#endif
@@ -214,6 +228,16 @@
return true;
}
+#if defined(OS_LINUX)
+int GetLoggingFileDescriptor() {
+ // No locking needed, since this is only called by the zygote server,
+ // which is single-threaded.
+ if (log_file)
+ return fileno(log_file);
+ return -1;
+}
+#endif
+
void InitLogMutex() {
#if defined(OS_WIN)
if (!log_mutex) {
« no previous file with comments | « base/logging.h ('k') | base/process_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698