Daemon: fix handling of errors from xread and xwrite.