Subject: Re: ps and PID
To: None <oinkfreebiker@att.net>
From: Robert Elz <kre@munnari.OZ.AU>
List: netbsd-help
Date: 07/27/2001 22:46:15
Date: Fri, 27 Jul 2001 15:06:32 +0000
From: oinkfreebiker@att.net
Message-ID: <20010727150634.LANB18077.mtiwmhc26.worldnet.att.net@webmail.worldnet.att.net>
| Where does ps get the PIDS which it reports?
From the kernel.
| I'm wondering because I use find to look for nmbd's
| PID and find it in /var/run/samba but I find inetd's
| PID in /var/run.
The files containing pids are just there as a convenience for some
other process that might need to know them (or you, if you need to
find them). They're (usually) created by the process itself, and
then removed before it exits. Of course, if the process crashes
(or the system crashes) it doesn't get a chance to remove that file
and it can contain old stuff from the past. Files in /var/run will
be removed when the system boots, so system crashes get taken care
of, but process crashes can leave stray files around.
| I can't get nmbd to run as daemon. I check with ps and
| don't see nmbd listed.
Try "ps -p `cat /var/run/samba/nmbd.pid`"
(without the "" quotes, but with the ` quotes, which are not ' quotes).
If that can't find the process, then it isn't running, and for some reason
nmbd is exiting - you probably need to find its log file, and figure out
why it is exiting, or perhaps look for a core file (nmbd.core) somewhere
and see if it is crashing.
| I'm wondering: should nmbd's
| PID be in /var/run/samba? Why isn't it in /var/run?
Where the samba authors or NetBSD samba package makers decided to stick it.
That isn't real important to anything.
| Is ps not listing nmbd's PID because it is in
| /var/run/samba instead of in /var/run?
No, 99% of processes that are run don't create .pid files at all.
| Is kill reporting
| "no such process" because nmbd's PID is not in /var/run
| but rather in /var/run/samba?
No, that's another fairly good clue (especially if you're running kill
as root) that the nmbd isn't running. Of course, if you ever managed
to successfully kill it, then that would explain things - and if killed
it might not get an opportunity to delete its pid file either.
| Or is /var/run/samba okay for nmbd's PID and nmbd truly
| isn't running?
That would be my guess. You need to find out why. I don't know much
about samba - can you run nmbd without it being a daemon (many daemons
have an option to just remain running on the terminal - sometimes with
extra debugging turned on as well - then you might get to see why it
exits - perhaps you have a config file problem or something).
kre