FreeBSD Bugzilla – Attachment 121875 Details for
Bug 164947
[patch] tee(1) loses data when writing to non-blocking file descriptors
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
file.txt
file.txt (text/plain), 1.04 KB, created by
Diomidis Spinellis
on 2012-02-10 07:10:09 UTC
(
hide
)
Description:
file.txt
Filename:
MIME Type:
Creator:
Diomidis Spinellis
Created:
2012-02-10 07:10:09 UTC
Size:
1.04 KB
patch
obsolete
>--- tee.c 2012/02/08 14:50:10 1.1 >+++ tee.c 2012/02/08 14:59:10 >@@ -46,8 +46,10 @@ > #endif /* not lint */ > > #include <sys/types.h> >+#include <sys/select.h> > #include <sys/stat.h> > #include <err.h> >+#include <errno.h> > #include <fcntl.h> > #include <signal.h> > #include <stdio.h> >@@ -64,6 +66,7 @@ > > void add(int, const char *); > static void usage(void); >+static void waitfor(int fd); > > int > main(int argc, char *argv[]) >@@ -110,9 +113,14 @@ > bp = buf; > do { > if ((wval = write(p->fd, bp, n)) == -1) { >- warn("%s", p->name); >- exitval = 1; >- break; >+ if (errno == EAGAIN) { >+ waitfor(p->fd); >+ wval = 0; >+ } else { >+ warn("%s", p->name); >+ exitval = 1; >+ break; >+ } > } > bp += wval; > } while (n -= wval); >@@ -141,3 +149,15 @@ > p->next = head; > head = p; > } >+ >+/* Wait for the specified fd to be ready for writing */ >+static void >+waitfor(int fd) >+{ >+ fd_set writefds; >+ >+ FD_ZERO(&writefds); >+ FD_SET(fd, &writefds); >+ if (select(fd + 1, NULL, &writefds, NULL, NULL) == -1) >+ err(1, "select"); >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 164947
: 121875