python-ptrace icon indicating copy to clipboard operation
python-ptrace copied to clipboard

Method `isTraced` is implemented incorrectly

Open gipi opened this issue 2 years ago • 0 comments

The implementation

class PTraceProcess:
  ...
    def isTraced(self):
        if not HAS_PROC:
            self.notImplementedError()
        stat = readProcessStat(self.pid)
        return (stat.state == 'T')

is checking for T, but that is for stopped by a signal; from man proc:

       /proc/[pid]/stat
              Status information about the process.  This is used by ps(1).  It is defined in the kernel source file fs/proc/array.c.
              ...
              (3) state  %c
                     One of the following characters, indicating process state:

                    ....
                     T  Stopped (on a signal) or (before Linux 2.6.33) trace stopped

                     t  Tracing stop (Linux 2.6.33 onward)

should be t. Probably class ProcessState needs reworking too.

gipi avatar Oct 10 '23 10:10 gipi