Also check that we wrote the amount we expected to. The write on the pty
is blocking but we could still get a short write on EINTR, so we should
SYSERROR it.
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
{
char buf[1024];
int *peer = (int *)data;
- int r;
+ int r,w;
r = read(fd, buf, sizeof(buf));
if (r < 0) {
SYSERROR("failed to read");
return 1;
}
- r = write(*peer, buf, r);
+ w = write(*peer, buf, r);
+ if (w < 0 || w != r) {
+ SYSERROR("failed to write");
+ return 1;
+ }
return 0;
}