lib: Add SAFE_WAIT() and SAFE_WAITPID()

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>