15#ifdef CATCH_PLATFORM_MAC
19# include <sys/types.h>
24#ifdef __apple_build_version__
27# include <sys/sysctl.h>
31 #ifdef __apple_build_version__
39 struct kinfo_proc info;
45 info.kp_proc.p_flag = 0;
52 mib[2] = KERN_PROC_PID;
58 if( sysctl(mib,
sizeof(mib) /
sizeof(*mib), &info, &size,
nullptr, 0) != 0 ) {
59 Catch::cerr() <<
"\n** Call to sysctl failed - unable to determine if debugger is active **\n" << std::endl;
65 return ( (info.kp_proc.p_flag & P_TRACED) != 0 );
75#elif defined(CATCH_PLATFORM_LINUX)
91 std::ifstream in(
"/proc/self/status");
92 for( std::string line; std::getline(in, line); ) {
93 static const int PREFIX_LEN = 11;
94 if( line.compare(0, PREFIX_LEN,
"TracerPid:\t") == 0 ) {
98 return line.length() > PREFIX_LEN && line[PREFIX_LEN] !=
'0';
105#elif defined(_MSC_VER)
106 extern "C" __declspec(dllimport)
int __stdcall IsDebuggerPresent();
109 return IsDebuggerPresent() != 0;
112#elif defined(__MINGW32__)
113 extern "C" __declspec(dllimport)
int __stdcall IsDebuggerPresent();
116 return IsDebuggerPresent() != 0;