-1

I'm trying to figure out whether I have a leak in file descriptors using lsof. The -c option to lsof is defined as:

  • Selects the listing of files for processes executing the command that begins with the characters of c.

If that's true then why do these two commands report different numbers?

$ lsof -c gunicorn | wc -l
589
$ lsof | grep ^gunicorn | wc -l
29154
marcsetgo
  • 33
  • 1
  • 1
  • 5
  • 3
    Have you considered looking at the lines and seeing what the difference is? – that other guy May 27 '20 at 22:50
  • When I try this with a few different programs, the answers are only off by 1 (because the first command counts the heading line). – Barmar May 27 '20 at 23:01
  • Are you sure you had the `^` character in the second command? If not, you'll match `gunicorn` anywhere on the line, not just the command name. – Barmar May 27 '20 at 23:01

1 Answers1

0

The default lsof will output the the main process and the threads with a TID (Thread ID) However, if you if you filter the output using a -c, only process opened files are listed, without TID. You will notice this if you look at the headers of the two outputs, ´lsof -c´ output is missing the TID column.

You can read more about TID in the man page.

Geeshan
  • 506
  • 5
  • 13