Commit aae15542 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(main): Write more than a single byte in the final write.

parent 296de631
...@@ -572,9 +572,10 @@ main(int argc, ...@@ -572,9 +572,10 @@ main(int argc,
for (retry = 3; again && retry > 0; retry--) for (retry = 3; again && retry > 0; retry--)
{ {
again = 0; again = 0;
switch (write(server, "\n", 1)) memset(buf, '\n', sizeof(buf));
rv = write(server, buf, sizeof(buf));
if (rv == -1)
{ {
case -1:
if (retry > 1 && (errno == EAGAIN || errno == EWOULDBLOCK if (retry > 1 && (errno == EAGAIN || errno == EWOULDBLOCK
|| errno == EINTR)) || errno == EINTR))
{ {
...@@ -586,20 +587,12 @@ main(int argc, ...@@ -586,20 +587,12 @@ main(int argc,
/* We expect EPIPE or ECONNRESET. */ /* We expect EPIPE or ECONNRESET. */
else if (errno != EPIPE && errno != ECONNRESET) else if (errno != EPIPE && errno != ECONNRESET)
fprintf(stderr, "final write: %s\n", strerror(errno)); fprintf(stderr, "final write: %s\n", strerror(errno));
break; }
if (rv == 0)
case 0:
fprintf(stderr, "final write returned 0\n"); fprintf(stderr, "final write returned 0\n");
break;
case 1: if (rv > 0)
fprintf(stderr, "ERROR: final write succeeded\n"); fprintf(stderr, "ERROR: final write succeeded: %d\n", (int)rv);
break;
default:
fprintf(stderr, "insane return value from final write\n");
break;
}
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment