File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -360,30 +360,33 @@ bool ISystem::isDebuggerAttached()
360360#include < sys/stat.h>
361361#include < fcntl.h>
362362#include < unistd.h>
363+ #include < cstring>
363364
364365bool ISystem::isDebuggerAttached ()
365366{
366367 constexpr char debuggerPidStr[] = " TracerPid:" ;
367368 constexpr size_t bufSize = 4096 ;
368- char buf[bufSize];
369369
370- const int status = open (" /proc/self/status" );
370+ const int status = open (" /proc/self/status" , O_RDONLY );
371371 if (status == -1 )
372372 return false ;
373373
374- const size_t numRead = read (status, static_cast <void *>(buf), sizeof (buf) - 1 );
374+ char buf[bufSize];
375+ const size_t numRead = read (status, static_cast <void *>(buf), bufSize - 1 );
375376 close (status);
376377
377378 buf[numRead] = ' \0 ' ;
378379 const auto offset = strstr (buf, debuggerPidStr);
379380 if (not offset)
380381 return false ;
381382
382- auto isSpace = [](const char c) { return c == ' ' ; };
383+
384+ auto isSpace = [](const char c) { return c == ' ' || c == ' \t ' ; };
383385 auto isDigit = [](const char c) { return c >= ' 0' && c <= ' 9' ; };
384386
385387 for (const char * cPtr = offset + sizeof (debuggerPidStr) - 1 ; cPtr <= buf + numRead; cPtr++)
386388 {
389+ std::cout << static_cast <int >(*cPtr) << " \n " ;
387390 if (isSpace (*cPtr))
388391 continue ;
389392 else
You can’t perform that action at this time.
0 commit comments