Fix ProcAPI::buildPidList() on mac os x and bsd. #3617

When retrieving the full list of pids on the system, be more resilient
to recoverable errors and don't return junk on failure.
* Retry sysctl() several times on ENOMEM failures.
* Don't return unitialized data when returning with failure.
* Improve logging on failure.
* Callers should check for failure.

Before these changes, daemons (especially the procd) can crash or
believe all processes on the system have exited.