Introduce UnexpectedError to handle non-fatal failures.

The error message is printed to stderr, and the function does not exit.
Fix linking after introduction of Unexpected Error
Handle return value from various C library and system calls
in cf-monitord and documentation tools.
Handle return values from chmod/chown/chdir
Handle parse errors in scanf calls.
Handle error code from fgets.

Also note that fgets should receive the size of the buffer including the
null terminator (ie writes num-1 bytes and sets the null terminator).