From: Simone Piccardi Date: Tue, 21 Aug 2007 18:07:07 +0000 (+0000) Subject: Il flag {{{SPLICE_F_NONBLOCK}}} fa si che ritorni {{{EAGAIN}}} anche X-Git-Url: https://gapil.gnulinux.it/gitweb/?a=commitdiff_plain;h=102049e7a564ba91d336f7c9b2f027067f9c48dd;p=gapil.git Il flag {{{SPLICE_F_NONBLOCK}}} fa si che ritorni {{{EAGAIN}}} anche quando la pipe in ingresso non contiene dati, se non lo si usa in quel caso {{{tee}}} ritorna semplicemente con un valore nullo. --- diff --git a/sources/tee.c b/sources/tee.c index 559c949..d876ad9 100644 --- a/sources/tee.c +++ b/sources/tee.c @@ -115,7 +115,8 @@ int main(int argc, char *argv[]) /* tee loop */ while (1) { /* copy stdin to stdout */ - len = tee(STDIN_FILENO, STDOUT_FILENO, size, SPLICE_F_NONBLOCK); + len = tee(STDIN_FILENO, STDOUT_FILENO, size, 0); + fprintf(stderr, "Copied %d byte\n", len); /* debug (use stderr!) */ if (len == 0) break; if (len < 0) { if (errno == EAGAIN) { @@ -125,7 +126,6 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } } - fprintf(stderr, "Copied %d byte\n", len); /* debug (use stderr!) */ /* write data to the file using splice */ while (len > 0) { nwrite = splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);