Provide a better error message when read returns 0

This prevents error messages that look like the following:
read: Success
_comm_recv: Read error while reading from socket.
Compile with -pthread rather than -lpthread

The correct way to compile pthread programs is with -pthread rather than
with -lpthread.  "-pthread" sets the correct options for the
preprocessor and the linker.
Prevent invalid free() if slave disappears

data should be initialized to NULL so that it is not freed at the end of
comm_recv if no data is read.
Merge pull request #1 from rosslagerwall/misc-fixes

Misc fixes