According to What does the “interruptible sleep” state indicate? there is a state called "T".

I tried to run a python script with strace but /proc/pid/stat still showed the the process was in S, waiting on do_wait (cat /proc/6145/wchan -> do_wait)

def f():
    import pdb

  • T state means the process is being traced, not tracing others Aug 12 '19 at 23:40
  • @炸鱼薯条德里克I tried looking at stat of the program being traced (python script), still under S. Not T.
    – CppLearner
    Aug 12 '19 at 23:43

You seem to have T mixed up with t. From man ps:

               T    stopped by job control signal
               t    stopped by debugger during the tracing

Anyway, to put a process in state T (stopped), kill -STOP its PID, or hit Ctrl+Z while it's running in the terminal. To put a process in state t (being traced), attach to it with ptrace, but don't let it continue like strace does. One way to do this is run gdb, then attach to its PID.

  • strace is using PTRACE_SEIZE, and simply gdb -p PID will work.
    – mosvy
    Aug 13 '19 at 1:44
  • Thank you very much!!
    – CppLearner
    Aug 13 '19 at 23:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.