Posix_kill is not so reliable (it seems it always deliver the signal - even 0 to a no existing process - and doesn't generate an error).
I found this way to check the existence of a process, using /proc:
if(!file_exists("/proc/$pid/cmdline"
obviously check the permissions .