1

I'm trying to read from /proc/<PID>/maps file. I ptrace(PTRACE_ATTACH, <PID>) before reading (so, the process is supposed to be suspended).

The code that reads looks like this:

while(fgets(line_buf, BUFSIZ, maps_fd) != NULL){ ... } 

but it's not ending (infinite loop). I did a printf line_buf and in turns out fgets it reading lines that it has read already.

Questions: What could be changing my maps file? (if anything is changing it)

If the file ins't changed by something else, why is fgets reading lines that it has read already?

alexandernst
  • 14,352
  • 22
  • 97
  • 197

1 Answers1

1

I can't find the reference right now, but this was a known bug/regression in certain kernel versions. The problem is almost surely that you're running on a buggy kernel and need to replace it with a less-buggy one. If I can find a link to the issue report I'll add it.

R.. GitHub STOP HELPING ICE
  • 208,859
  • 35
  • 376
  • 711