| diff --git src/gtest-port.cc b/src/gtest-port.cc |
| index b860d48..acb459b 100644 |
| --- a/src/gtest-port.cc |
| +++ b/src/gtest-port.cc |
| @@ -35,6 +35,8 @@ |
| #include <stdlib.h> |
| #include <stdio.h> |
| #include <string.h> |
| +#include <sys/types.h> |
| +#include <dirent.h> |
| |
| #if GTEST_OS_WINDOWS_MOBILE |
| # include <windows.h> // For TerminateProcess() |
| @@ -98,6 +98,21 @@ size_t GetThreadCount() { |
| } |
| } |
| |
| +#elif GTEST_OS_LINUX |
| + |
| +size_t GetThreadCount() { |
| + size_t thread_count = 0; |
| + if (DIR *dir = opendir("/proc/self/task")) { |
| + while (dirent *entry = readdir(dir)) { |
| + if (strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0) { |
| + ++thread_count; |
| + } |
| + } |
| + closedir(dir); |
| + } |
| + return thread_count; |
| +} |
| + |
| #else |
| |
| size_t GetThreadCount() { |
| diff --git a/src/gtest-death-test.cc b/src/gtest-death-test.cc |
| index 8b2e413..faad3a4 100644 |
| --- a/src/gtest-death-test.cc |
| +++ b/src/gtest-death-test.cc |
| @@ -44,6 +44,8 @@ |
| # include <fcntl.h> |
| # include <limits.h> |
| # include <stdarg.h> |
| +# include <sys/time.h> |
| +# include <sys/resource.h> |
| |
| # if GTEST_OS_WINDOWS |
| # include <windows.h> |
| @@ -898,6 +900,11 @@ inline char** GetEnviron() { return environ; } |
| // This function is called in a clone()-ed process and thus must avoid |
| // any potentially unsafe operations like malloc or libc functions. |
| static int ExecDeathTestChildMain(void* child_arg) { |
| + rlimit core_rlimit; |
| + core_rlimit.rlim_cur = 0; |
| + core_rlimit.rlim_max = 0; |
| + GTEST_DEATH_TEST_CHECK_SYSCALL_(setrlimit(RLIMIT_CORE, &core_rlimit)); |
| + |
| ExecDeathTestArgs* const args = static_cast<ExecDeathTestArgs*>(child_arg); |
| GTEST_DEATH_TEST_CHECK_SYSCALL_(close(args->close_fd)); |