Linux Process: Difference between revisions
Jump to navigation
Jump to search
(새 문서: == Processes states == <code>D Uninterruptible sleep (usually IO) R Running or runnable (on run queue) S Interruptible sleep (waiting for an event to complete) T Stopped, either by a job control signal or because it is being traced. W paging (not valid since the 2.6.xx kernel) X dead (should never be seen) Z Defunct ("zombie") process, terminated but not reaped by its parent.</code> <code>< high-priority (not nice to other users) N low-priority (nice to other users) L...) |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== Processes states == | == Processes states == | ||
S Interruptible sleep (waiting for an event to complete) | |||
D Uninterruptible sleep (usually IO) | |||
R Running or runnable (on run queue) | R Running or runnable (on run queue) | ||
T Stopped, either by a job control signal or because it is being traced. | T Stopped, either by a job control signal or because it is being traced. | ||
W paging (not valid since the 2.6.xx kernel) | W paging (not valid since the 2.6.xx kernel) | ||
X dead (should never be seen) | X dead (should never be seen) | ||
Z Defunct ("zombie") process, terminated but not reaped by its parent. | Z Defunct ("zombie") process, terminated but not reaped by its parent. | ||
< | << high-priority (not nice to other users) | ||
N low-priority (nice to other users) | N low-priority (nice to other users) | ||
L has pages locked into memory (for real-time and custom IO) | L has pages locked into memory (for real-time and custom IO) | ||
s is a session leader | s is a session leader | ||
l is multi-threaded (using CLONE_THREAD, like NPTL pthreads do) | l is multi-threaded (using CLONE_THREAD, like NPTL pthreads do) | ||
+ is in the foreground process group</code> | + is in the foreground process group | ||
[[File:Linux Process States.png|frameless|center|388x388px|<ref>https://www.baeldung.com/linux/process-states</ref>]] | |||
We can feel 'stuck' when a process goes into the "D" state usually, from time to time, Nvidia installer shows "D" state without any usefull logs when trying to install driver. | |||
'''We cannot kill "D" state processes, even with [[Linux signal|SIGKILL or kill -9]]'''. As the name implies, they are uninterruptible. You can only clear them by rebooting the server or waiting for the I/O to respond. | |||
== How to know where a process was started and how it was started? == | |||
Most reliable way is to look at the <code>/proc, /proc/<pid>/ directory where it keeps information like:</code><ref>https://serverfault.com/questions/232762/linux-how-to-know-where-a-process-was-started-and-how-it-was-started</ref> | |||
# <code>cwd link to the current working directory</code> | |||
# <code>fd a dir with links to the open files (file descriptors)</code> | |||
# <code>cmdline read it to see what command line was used to start the process</code> | |||
# <code>environ the environment variables for that process</code> | |||
# <code>root a link to what the process considers it's root dir (it will be / unless chrooted)</code> | |||
<code>pstree -sp <PID></code> also give clearer relationship in tree view | |||
<code>systemctl status <PID></code> | |||
== References == | |||
<references /> |
Latest revision as of 08:58, 28 July 2023
Processes states
S Interruptible sleep (waiting for an event to complete) D Uninterruptible sleep (usually IO) R Running or runnable (on run queue) T Stopped, either by a job control signal or because it is being traced. W paging (not valid since the 2.6.xx kernel) X dead (should never be seen) Z Defunct ("zombie") process, terminated but not reaped by its parent.
<< high-priority (not nice to other users) N low-priority (nice to other users) L has pages locked into memory (for real-time and custom IO) s is a session leader l is multi-threaded (using CLONE_THREAD, like NPTL pthreads do) + is in the foreground process group
We can feel 'stuck' when a process goes into the "D" state usually, from time to time, Nvidia installer shows "D" state without any usefull logs when trying to install driver.
We cannot kill "D" state processes, even with SIGKILL or kill -9. As the name implies, they are uninterruptible. You can only clear them by rebooting the server or waiting for the I/O to respond.
How to know where a process was started and how it was started?
Most reliable way is to look at the /proc, /proc/<pid>/ directory where it keeps information like:
[2]
cwd link to the current working directory
fd a dir with links to the open files (file descriptors)
cmdline read it to see what command line was used to start the process
environ the environment variables for that process
root a link to what the process considers it's root dir (it will be / unless chrooted)
pstree -sp <PID>
also give clearer relationship in tree view
systemctl status <PID>