Technology Sharing

What do the parameters printed out by adb shell ps -T mean, and what do the statuses represented by D, T, and Z mean?

2024-07-11

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

In Android, useadb shell psThe command can view the process information running in the current system. When you add-Toption (note that the standardpsCommands in Androidadb shellMay not be directly supported in-Toption, which is usually the same as the LinuxpsThe command is slightly different), you may want to see more detailed thread information, but the standardadb shell psCommands are not directly supported-Tto list the threads. However, we can discusspsThe general meaning of command output and the meaning of process status (such as D, T, Z).

adb shell psGeneral meaning of the output

On Androidadb shellmiddle,psCommands are usually not provided-Toption to list threads directly. However, it can list information about processes, including:

  • UID: User ID, indicating the user running the process.
  • PID: Process ID, which is the unique identifier of a process.
  • PPID: Parent process ID, which is the ID of the process that created this process.
  • VSZ: Virtual memory size, which indicates the amount of virtual memory occupied by the process.
  • RSS: Resident set size, which indicates the amount of physical memory currently occupied by the process.
  • NAME: Process name or command line.

Meaning of process status (D, T, Z)

In Linux (including the underlying Android),psThe output of the command usually contains the status of the process. These status codes can include D, T, Z, etc., which represent different process states:

  • D (Uninterruptible sleep state): The process is in an uninterruptible sleeping state, usually because it is waiting for an I/O (such as a disk write) operation to complete. In this state, even if a signal is sent to the process, it will not respond.

  • T (stop state): The process has been stopped (usually bystopSignals) can neither execute nor be terminated. However, a signal can be used to cause it to continue running or terminate.

  • Z (Zombie state): This is a process that has terminated, but its parent process has not yet passedwait()orwaitpid()The zombie process has released most of its resources but still retains a process table entry so that the parent process can query its status.

Please note that on Androidadb shell psThese status characters may not appear directly in command output (especially if the output is not specially configured or formatted) because they may require additionalpsOptions (such as-eo stateIn Linux, however, AndroidpsThe available options and output formats of the command may differ from the standard Linux