diff --git a/Misc/README.md b/Misc/README.md index 58662996f76b17675e5f003b9701dc2d1504e5dc..e475ae6c33671428a9256c6621a514b4088005f9 100644 --- a/Misc/README.md +++ b/Misc/README.md @@ -30,3 +30,30 @@ There is a tool for investigative reporting at news organizations, that develope Note: Tabula only works on text-based PDFs, not scanned documents. +## Q: What is my process doing? + +If you experience processes that are slower than they should be or you are unsure what it is doing. There are certain ways to get more information. + +### Process States +For example if you run `ps ux` or `htop` and check your process, you should see a state with the following meaning: + + D = UNINTERRUPTABLE_SLEEP + R = RUNNING & RUNNABLE + S = INTERRRUPTABLE_SLEEP + T = STOPPED + Z = ZOMBIE + +Processes in a **"D"** or uninterruptible sleep state are usually waiting on I/O. The ps command shows a "D" on processes in an uninterruptible sleep state. The vmstat command also shows the current processes that are "blocked" or waiting on I/O. The vmstat and ps will not agree on the number of processes in a "D" state, so don't be too concerned. You 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. It is normal to see processes in a "D" state when the server performs I/O intensive operations. + +As root you can do `echo w > /proc/sysrq-trigger` and check the `dmesg -T` what the stacktrace reports. + +Processes in a **"S"** or interruptable sleep state are waiting for the user or data to continue. Unlike processes in a **"T"** or stopped state, which must have been suspended, with e.g. Ctrl+Z. Using `jobs` to see what processees you have or running `fg` to get the processes back to your command line. + +Processes in a **"Z"** or zombie state are being terminated by the parent processes. If the parent did not clean up, a zombie processes lingers. + +**How to kill a zombie processes?** + The first step is to find its parent process. Typically there is a column in the "ps" output for PPID or Parent Process ID. You want to identify this number. Once you do you can send a SIGCHLD signal to that parent to tell it to perform this cleanup. + +`kill -s SIGCHLD <PPID>` + +In worst case scenarios where the parent is generating a lot of zombie processes that are not getting cleaned up, you can kill or restart the parent.