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()
360
360
#include < sys/stat.h>
361
361
#include < fcntl.h>
362
362
#include < unistd.h>
363
+ #include < cstring>
363
364
364
365
bool ISystem::isDebuggerAttached ()
365
366
{
366
367
constexpr char debuggerPidStr[] = " TracerPid:" ;
367
368
constexpr size_t bufSize = 4096 ;
368
- char buf[bufSize];
369
369
370
- const int status = open (" /proc/self/status" );
370
+ const int status = open (" /proc/self/status" , O_RDONLY );
371
371
if (status == -1 )
372
372
return false ;
373
373
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 );
375
376
close (status);
376
377
377
378
buf[numRead] = ' \0 ' ;
378
379
const auto offset = strstr (buf, debuggerPidStr);
379
380
if (not offset)
380
381
return false ;
381
382
382
- auto isSpace = [](const char c) { return c == ' ' ; };
383
+
384
+ auto isSpace = [](const char c) { return c == ' ' || c == ' \t ' ; };
383
385
auto isDigit = [](const char c) { return c >= ' 0' && c <= ' 9' ; };
384
386
385
387
for (const char * cPtr = offset + sizeof (debuggerPidStr) - 1 ; cPtr <= buf + numRead; cPtr++)
386
388
{
389
+ std::cout << static_cast <int >(*cPtr) << " \n " ;
387
390
if (isSpace (*cPtr))
388
391
continue ;
389
392
else
You can’t perform that action at this time.
0 commit comments