V
V
Vitaly2021-03-25 21:37:02
linux
Vitaly, 2021-03-25 21:37:02

Why are the number of running processes in htop, pgrep, ps different?

Why htop shows a huge number of firefox-esr processes (the toaster does not allow you to insert a screenshot)
At the same time, pgrep only 2 pcs.

$ pgrep firefox-esr
548
1035


A ps - 9 pcs.
$ ps -aux | grep firefox
vit       3356 16.0 12.6 2778852 258720 ?      Sl   19:34   0:48 firefox-esr -marionette --no-sandbox -foreground -no-remote -profile /tmp/rust_mozprofileWxTvQG
vit       3573  4.3  6.5 2494028 133704 ?      Sl   19:34   0:13 /usr/lib/firefox-esr/firefox-esr -contentproc -childID 1 -isForBrowser -prefsLen 1 -prefMapSize 213807 -parentBuildID 20210119174753 -appdir /usr/lib/firefox-esr/browser 3356 true tab
vit       3587  0.2  4.8 2395568 99284 ?       Sl   19:34   0:00 /usr/lib/firefox-esr/firefox-esr -contentproc -childID 2 -isForBrowser -prefsLen 85 -prefMapSize 213807 -parentBuildID 20210119174753 -appdir /usr/lib/firefox-esr/browser 3356 true tab
vit       3637 16.2 12.8 2790112 261768 ?      Sl   19:34   0:48 firefox-esr -marionette --no-sandbox -foreground -no-remote -profile /tmp/rust_mozprofileD6HG2V
vit       3698  0.0  3.2 2378440 65756 ?       Sl   19:34   0:00 /usr/lib/firefox-esr/firefox-esr -contentproc -childID 3 -isForBrowser -prefsLen 9800
-prefMapSize 213807 -parentBuildID 20210119174753 -appdir /usr/lib/firefox-esr/browser 3356 true tab
vit       3716  4.5  6.4 2471380 132308 ?      Sl   19:34   0:13 /usr/lib/firefox-esr/firefox-esr -contentproc -childID 1 -isForBrowser -prefsLen 1 -prefMapSize 213807 -parentBuildID 20210119174753 -appdir /usr/lib/firefox-esr/browser 3637 true tab
vit       3740  0.2  4.8 2396088 98840 ?       Sl   19:34   0:00 /usr/lib/firefox-esr/firefox-esr -contentproc -childID 2 -isForBrowser -prefsLen 85 -prefMapSize 213807 -parentBuildID 20210119174753 -appdir /usr/lib/firefox-esr/browser 3637 true tab
vit       3800  0.0  3.2 2378440 66576 ?       Sl   19:34   0:00 /usr/lib/firefox-esr/firefox-esr -contentproc -childID 3 -isForBrowser -prefsLen 9800
-prefMapSize 213807 -parentBuildID 20210119174753 -appdir /usr/lib/firefox-esr/browser 3637 true tab
vit       5393  0.0  0.0   6208   828 pts/2    S+   19:39   0:00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox firefox


Once a day I remove hanging processes with pgrep firefox | xargs kill -9
But it seems that most of the processes are not killed, since htop gives a different output

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Saboteur, 2021-03-26
@vitalysokolov

pgrep searches for process name
ps aux on the command line
try comparing the number of processes using "pgrep -f" and "ps aux" - should match.

N
neol, 2021-03-25
@neol

htop does not show processes, but threads ( F2 - Display Options - Hide userland process threads )
pgrep searches by default in the process name, not in the path to the binary (pgrep -f firefox will search in the path), and ps displays once the paths

Once a day I remove hanging processes with pgrep firefox | xargs kill -9

Well... Everyone has their flaws.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question