From 9642443a7c283d2be49859607d5daaa2f84694b3 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Sun, 22 Oct 2017 11:16:10 +0200 Subject: [PATCH] Clean up redirect example a bit Signed-off-by: Joachim Nilsson --- examples/redirect.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/examples/redirect.c b/examples/redirect.c index 3e51c9f..1e7d3b2 100644 --- a/examples/redirect.c +++ b/examples/redirect.c @@ -17,20 +17,14 @@ #include #include "src/uev.h" -/* - * When stdin becomes ready to be read from, this callback is invoked by - * libuEv. We just print out the data. - */ void process_stdin(uev_t *w, void *arg, int events) { char buf[256]; int len; - fprintf(stderr, "process_stdin() called with fd: %d, events: 0x%x\n", w->fd, events); - len = read(w->fd, buf, sizeof(buf)); if (len == -1) { - perror("Reading from stdin."); + perror("Error reading from stdin"); return; } @@ -39,9 +33,9 @@ void process_stdin(uev_t *w, void *arg, int events) return; } - fprintf(stdout, "--- read %d bytes\n", len); + fprintf(stdout, "Read %d bytes\n", len); if (write(STDOUT_FILENO, buf, len) != len) - fprintf(stdout, "--- failed writing\n"); + perror("Failed writing to stdout"); } int main(int argc, char **argv) @@ -50,10 +44,8 @@ int main(int argc, char **argv) uev_t watcher; uev_ctx_t ctx; - /* Initalize the event library */ uev_init(&ctx); - /* Bind an to a read-ready event on the new socket and activate. */ ret = uev_io_init(&ctx, &watcher, process_stdin, NULL, STDIN_FILENO, UEV_READ); if (ret) perror("Failed setting up STDIN watcher");