Returning with an error

To reply to the client such that the function the client is calling (e.g. read()) will return with an error, you simply return with an appropriate errno value (from <errno.h>).

return (ENOMEM);

In the case of a read(), this causes the read to return -1 with errno set to ENOMEM.

Note: You might sometimes see this in the code for a resource manager:
_RESMGR_ERRNO (error_code)

but this is the same as simply returning the error_code directly. The _RESMGR_ERRNO() macro is deprecated.