blob: cbf7294d08f0dcfefb6fefd340e172045b73fd1e [file] [log] [blame]
Brian Silverman0f17ab62013-09-23 17:56:13 -07001diff --git src/gtest-port.cc b/src/gtest-port.cc
2index b860d48..acb459b 100644
3--- a/src/gtest-port.cc
4+++ b/src/gtest-port.cc
5@@ -98,6 +98,21 @@ size_t GetThreadCount() {
6 }
7 }
brians343bc112013-02-10 01:53:46 +00008
Brian Silverman0f17ab62013-09-23 17:56:13 -07009+#elif GTEST_OS_LINUX
brians343bc112013-02-10 01:53:46 +000010+
Brian Silverman0f17ab62013-09-23 17:56:13 -070011+size_t GetThreadCount() {
12+ size_t thread_count = 0;
13+ if (DIR *dir = opendir("/proc/self/task")) {
14+ while (dirent *entry = readdir(dir)) {
15+ if (strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0) {
16+ ++thread_count;
17+ }
18+ }
19+ closedir(dir);
brians343bc112013-02-10 01:53:46 +000020+ }
Brian Silverman0f17ab62013-09-23 17:56:13 -070021+ return thread_count;
brians343bc112013-02-10 01:53:46 +000022+}
brians343bc112013-02-10 01:53:46 +000023+
Brian Silverman0f17ab62013-09-23 17:56:13 -070024 #else
25
26 size_t GetThreadCount() {
27diff --git a/src/gtest-death-test.cc b/src/gtest-death-test.cc
28index 8b2e413..faad3a4 100644
29--- a/src/gtest-death-test.cc
30+++ b/src/gtest-death-test.cc
31@@ -44,6 +44,8 @@
32 # include <fcntl.h>
33 # include <limits.h>
34 # include <stdarg.h>
35+# include <sys/time.h>
36+# include <sys/resource.h>
37
38 # if GTEST_OS_WINDOWS
39 # include <windows.h>
40@@ -898,6 +900,11 @@ inline char** GetEnviron() { return environ; }
41 // This function is called in a clone()-ed process and thus must avoid
42 // any potentially unsafe operations like malloc or libc functions.
43 static int ExecDeathTestChildMain(void* child_arg) {
44+ rlimit core_rlimit;
45+ core_rlimit.rlim_cur = 0;
46+ core_rlimit.rlim_max = 0;
47+ GTEST_DEATH_TEST_CHECK_SYSCALL_(setrlimit(RLIMIT_CORE, &core_limit));
48+
49 ExecDeathTestArgs* const args = static_cast<ExecDeathTestArgs*>(child_arg);
50 GTEST_DEATH_TEST_CHECK_SYSCALL_(close(args->close_fd));