diff --git a/examples/redirect.c b/examples/redirect.c index 1e7d3b2..178146b 100644 --- a/examples/redirect.c +++ b/examples/redirect.c @@ -12,6 +12,8 @@ * reading from stdin as a special case. */ +#include +#include #include #include #include @@ -24,18 +26,18 @@ void process_stdin(uev_t *w, void *arg, int events) len = read(w->fd, buf, sizeof(buf)); if (len == -1) { - perror("Error reading from stdin"); + warn("Error reading from stdin"); return; } if (len == 0) { - fprintf(stderr, "Connection closed.\n"); + warnx("Connection closed."); return; } - fprintf(stdout, "Read %d bytes\n", len); + printf("Read %d bytes\n", len); if (write(STDOUT_FILENO, buf, len) != len) - perror("Failed writing to stdout"); + warn("Failed writing to stdout"); } int main(int argc, char **argv) @@ -48,7 +50,7 @@ int main(int argc, char **argv) ret = uev_io_init(&ctx, &watcher, process_stdin, NULL, STDIN_FILENO, UEV_READ); if (ret) - perror("Failed setting up STDIN watcher"); + err(errno, "Failed setting up STDIN watcher"); return uev_run(&ctx, 0); }