aboutsummaryrefslogtreecommitdiff
path: root/src/common/linux/memory_mapped_file.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/linux/memory_mapped_file.cc')
-rw-r--r--src/common/linux/memory_mapped_file.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/common/linux/memory_mapped_file.cc b/src/common/linux/memory_mapped_file.cc
index 7e444607..a7b96eb5 100644
--- a/src/common/linux/memory_mapped_file.cc
+++ b/src/common/linux/memory_mapped_file.cc
@@ -29,6 +29,10 @@
// memory_mapped_file.cc: Implement google_breakpad::MemoryMappedFile.
// See memory_mapped_file.h for details.
+#ifdef HAVE_CONFIG_H
+#include <config.h> // Must come first
+#endif
+
#include "common/linux/memory_mapped_file.h"
#include <fcntl.h>
@@ -57,8 +61,11 @@ MemoryMappedFile::~MemoryMappedFile() {
bool MemoryMappedFile::Map(const char* path, size_t offset) {
Unmap();
-
- int fd = sys_open(path, O_RDONLY, 0);
+ // Based on https://pubs.opengroup.org/onlinepubs/7908799/xsh/open.html
+ // If O_NONBLOCK is set: The open() function will return without blocking
+ // for the device to be ready or available. Setting this value will provent
+ // hanging if file is not avilable.
+ int fd = sys_open(path, O_RDONLY | O_NONBLOCK, 0);
if (fd == -1) {
return false;
}