Is getpid supposed to return PID-1?
Hi, Thanks to everyone for the responses I got. Yes it was a bug in my code. I was simply calling getpid before the call to daemon(0,0). Once I moved the getpid further down it worked as expected. Kirby From: "Kevin Bohan" <kirby132@hotmail.com> To: darwin-kernel@lists.apple.com Subject: Is getpid supposed to return PID-1? Date: Tue, 13 Nov 2001 14:29:56 +0000 Hi, I have a BSD question and I apologise if this is not the right list, as this is not really my area. However I have a daemon that writes its PID to an external file when it starts up and I have a script that looks for this file, extracts the PID in order to provide a commandline interface that allows the process to be killed. However, when I call getpid to write the PID to the text file it always seems to write a value that is 1 less than the PID shown when I use ps to view the process in question. Also if I call kill on the value returned by getpid it tells me that the process doesn't exist. It would seem that ps is right an getpid is wrong. I can obviously just add one to the value returned by getpid, but is this safe/future-proof? Is this a known issue? What should I do? Kirby _________________________________________________________________ _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
participants (1)
-
Kevin Bohan