Subject: processes with closed file descriptors?
To: None <netbsd-users@NetBSD.ORG>
From: Greg Earle <earle@isolar.Tujunga.CA.US>
List: current-users
Date: 02/24/1995 00:10:08
I've ported lsof 3.19 to NetBSD 1.0 on a SPARC.  (Hopefully it will work for
-current as well.)

I got some strange output while testing which I'd attributed to either a bug
or unfinished business on my part:

netbsd4me:1:188 % lsof |& egrep COMMAND\|bad
COMMAND     PID     USER   FD   TYPE     DEVICE   SIZE/OFF  INODE NAME
ypbind       57     root    0u                                    bad mount for 0xf7fff1d0 at 0
ypbind       57     root    1u                                    bad mount for 0xf7fff1d0 at 0
ypbind       57     root    2u                                    bad mount for 0xf7fff1d0 at 0
cron         89     root    0u                                    bad mount for 0xf7fff1d0 at 0
cron         89     root    1u                                    bad mount for 0xf7fff1d0 at 0
cron         89     root    2u                                    bad mount for 0xf7fff1d0 at 0
afsd        130     root    0u                                    bad mount for 0xf7fff1d0 at 0
afsd        130     root    1u                                    bad mount for 0xf7fff1d0 at 0
afsd        130     root    2u                                    bad mount for 0xf7fff1d0 at 0

[ ... X 5 more times for the other 5 afsd's .... ]

xfs         167     root    1u                                    bad mount for 0xf7fff1d0 at 0

I thought, "I'll find out what these are; I'll use fstat(1)".

Well, fstat doesn't like them either:

netbsd4me# fstat | egrep CMD\|none
USER     CMD          PID   FD MOUNT      INUM MODE         SZ|DV R/W
root     xfs          167    1 -         -        none    -
root     afsd         135    0 -         -        none    -
root     afsd         135    1 -         -        none    -
root     afsd         135    2 -         -        none    -

[ ... X 5 more times for the other 5 afsd's .... ]

root     cron          89    0 -         -        none    -
root     cron          89    1 -         -        none    -
root     cron          89    2 -         -        none    -
root     ypbind        57    0 -         -        none    -
root     ypbind        57    1 -         -        none    -
root     ypbind        57    2 -         -        none    -

I suspect that these processes have closed off all of these file descriptors,
but I looked at e.g. ypbind.c and saw nowhere in the code any close()'s or
dup()'s et al. that would indicate that the fd's were closed.  I ran "ypbind"
manually under "ktrace -i  -d" and saw no indication that stdin/stdout/stderr
are ever referenced.

Anyone surmise what's happening here?  Do stdin/stdout/stderr for some daemons
get "lost"?  Or are both programs at fault here for not interpreting something
in the correct way?  (Otherwise, "lsof" works perfectly.)

While I'm at it, "lsof" purports to support procfs.  There's a "procfs.h"
with a "struct pfsnode" in /usr/src/sys/miscfs/procfs, but nowhere under
/usr/include (at least, not in 1.0).  Should there be?
Thanks,

	- Greg