Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 Feb 1999 08:29:29 -0800 (PST)
From:      John Polstra <jdp@polstra.com>
To:        dirk.vangulik@jrc.it
Cc:        hackers@FreeBSD.ORG
Subject:   Re: My ignorance (lsof shows shared lib's).
Message-ID:  <199902101629.IAA53619@vashon.polstra.com>
In-Reply-To: <36C1ADBF.CE85DF2E@jrc.it>

next in thread | previous in thread | raw e-mail | index | archive | help
In article <36C1ADBF.CE85DF2E@jrc.it>,
Dirk-Willem van Gulik  <dirk.vangulik@jrc.it> wrote:
> Forgive me my ignorance; but why would one see open file descriptors
> for the shared libraries; long after (I would) assume that they have
> been read in and used. Is that not a one off thing ?
> 
> Dw.
> 
> httpsd    11646   nobody  txt   VREG   0,131077     422937  61527 
> 	/usr/lib/libc.so.3.1
> httpsd    11646   nobody  txt   VREG   0,131077      13581  92418 
> 	/usr/local/lib/perl5/i386-freebsd/5.00404/auto/IO/IO.so
> httpsd    11646   nobody  txt   VREG   0,131077     184758  77089 
> 	/usr/local/lib/perl5/site_perl/i386-freebsd/auto/GD/GD.so
> httpsd    11646   nobody  txt   VREG   0,131077      35724  77016
> 	/usr/local/lib/perl5/site_perl/i386-freebsd/auto/Storable/Storable.so
> httpsd    11646   nobody  txt   VREG   0,131077      56514  77052
> 	/usr/local/lib/perl5/site_perl/i386-freebsd/auto/DBI/DBI.so
> httpsd    11646   nobody  txt   VREG   0,131077      27887   8150 
> /usr/local/lib/perl5/i386-freebsd/5.00404/auto/DB_File/DB_File.so
> httpsd    11646   nobody  txt   VREG   0,131077      22054  92533 
> 	/usr/local/lib/perl5/site_perl/i386-freebsd/auto/DBMS/DBMS.so
> httpsd    11646   nobody  txt   VREG   0,131077     133977  38841 
> /usr/local/lib/perl5/site_perl/i386-freebsd/auto/XML/Parser/Expat/Expat.so

There aren't open file descriptors for the shared libraries.  I
checked the dynamic linker sources just to make sure.  It closes the
files as soon as they have been mapped into memory.

The reason lsof sees them is because they're memory mapped.  Shared
libraries aren't really "read in and used" all at once.  Instead,
they're mapped directly into the address space.  Over time, as the
process accesses various pages from the shared libraries, the pages
are demand-loaded from the files by the kernel.  Thus the process has
a grip on all the shared library files even though it no longer holds
open file descriptors for them.

John
-- 
  John Polstra                                               jdp@polstra.com
  John D. Polstra & Co., Inc.                        Seattle, Washington USA
  "Nobody ever went broke underestimating the taste of the American public."
                                                            -- H. L. Mencken

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199902101629.IAA53619>