Added the rest of the sd_pid_*() functions and efficiency improvements.

The next step is implementing logind's RPC interface.