Use pid_t for pids.
Style.

Use bool where applicable. Polish comments. Rename 'unlink' to 'orphan'.
Move exported functions to the top.
Simplify hier_prefix. Prevent prefix buffer underflow.