summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorrobert.nagy@gmail.com <robert.nagy@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-09 23:57:22 +0000
committerrobert.nagy@gmail.com <robert.nagy@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-09 23:57:22 +0000
commitb74c87d0c6648a2d0ed849f0be44a6f90356b6b6 (patch)
treeb8c2abf998296c705f6caf8904dc016408a25ac2 /ui
parentd9c1ade4d29daf457cadbfdf15c71e92e5ffeebb (diff)
downloadchromium_src-b74c87d0c6648a2d0ed849f0be44a6f90356b6b6.zip
chromium_src-b74c87d0c6648a2d0ed849f0be44a6f90356b6b6.tar.gz
chromium_src-b74c87d0c6648a2d0ed849f0be44a6f90356b6b6.tar.bz2
On FreeBSD we can't access the shared memory after it was marked for
deletion, unless this behaviour is explicitly enabled by the user. This behaviour can be enabled with the kern.ipc.shm_allow_removed sysctl variable which is set to 0 by default. In case it's not enabled we disable shm support. This is not an issue on OpenBSD because we are allowing this by default to follow what Linux does because most people will expect that. BUG= TEST= Review URL: http://codereview.chromium.org/8910016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116959 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/base/x/x11_util.cc18
1 files changed, 18 insertions, 0 deletions
diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc
index f16388a..6b11de4 100644
--- a/ui/base/x/x11_util.cc
+++ b/ui/base/x/x11_util.cc
@@ -29,6 +29,11 @@
#include "ui/gfx/rect.h"
#include "ui/gfx/size.h"
+#if defined(OS_FREEBSD)
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#endif
+
#if defined(TOOLKIT_USES_GTK)
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
@@ -228,6 +233,19 @@ static SharedMemorySupport DoQuerySharedMemorySupport(Display* dpy) {
if (!XShmQueryVersion(dpy, &dummy, &dummy, &pixmaps_supported))
return SHARED_MEMORY_NONE;
+#if defined(OS_FREEBSD)
+ // On FreeBSD we can't access the shared memory after it was marked for
+ // deletion, unless this behaviour is explicitly enabled by the user.
+ // In case it's not enabled disable shared memory support.
+ int allow_removed;
+ size_t length = sizeof(allow_removed);
+
+ if ((sysctlbyname("kern.ipc.shm_allow_removed", &allow_removed, &length,
+ NULL, 0) < 0) || allow_removed < 1) {
+ return SHARED_MEMORY_NONE;
+ }
+#endif
+
// Next we probe to see if shared memory will really work
int shmkey = shmget(IPC_PRIVATE, 1, 0666);
if (shmkey == -1)