summaryrefslogtreecommitdiffstats
path: root/base/logging.cc
diff options
context:
space:
mode:
authordkegel@google.com <dkegel@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-06 19:59:36 +0000
committerdkegel@google.com <dkegel@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-06 19:59:36 +0000
commit4883a4e4209bab557f4ba40a002936acf755205f (patch)
tree8b1aef5a4e1fe01ee5d4e178838dec8e98356177 /base/logging.cc
parente2ffeae017f1c85d472e3f04e62e4cba21f6e9a8 (diff)
downloadchromium_src-4883a4e4209bab557f4ba40a002936acf755205f.zip
chromium_src-4883a4e4209bab557f4ba40a002936acf755205f.tar.gz
chromium_src-4883a4e4209bab557f4ba40a002936acf755205f.tar.bz2
Prototype implementation of zygotes.
Limitations that need addressing still: - Doesn't forcibly terminate children that should have exited but haven't Enable with env var ENABLE_ZYGOTE_MANAGER=1. BUG=11841 TEST= start the browser, then make chrome and all .pak files unreadable; or alternately, start an installed browser, and uninstall the browser while it's running. Then create a new tab and browse to two new sites. Here's an example script to hide and unhide the .pak files (note: do not move the directory they're in, that doesn't work): #!/bin/sh chmod_all() { chmod $1 sconsbuild/Debug/chrome for path in . locales obj/chrome/app/intermediate/repack obj/global_intermediate/* themes do chmod $1 sconsbuild/Debug/$path/*.pak done } case $1 in hide) chmod_all 000 ;; show) chmod_all 755 ;; esac Review URL: http://codereview.chromium.org/115773 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17840 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/logging.cc')
-rw-r--r--base/logging.cc24
1 files changed, 24 insertions, 0 deletions
diff --git a/base/logging.cc b/base/logging.cc
index 7420883..b6aa730 100644
--- a/base/logging.cc
+++ b/base/logging.cc
@@ -19,9 +19,12 @@ typedef HANDLE MutexHandle;
#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 @@ typedef pthread_mutex_t* MutexHandle;
#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 @@ bool InitializeLogFileHandle() {
}
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 @@ bool InitializeLogFileHandle() {
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) {