Merge \"Improved error handling.\" into nyc-dev
am: bbd27419ac
Change-Id: I1cdfd89997adee7d68191b66bab9e437a8be7800
diff --git a/cmds/bugreportz/bugreportz.cpp b/cmds/bugreportz/bugreportz.cpp
index 19d2d64..312dceb 100644
--- a/cmds/bugreportz/bugreportz.cpp
+++ b/cmds/bugreportz/bugreportz.cpp
@@ -80,8 +80,8 @@
}
if (s == -1) {
- printf("Failed to connect to dumpstatez service: %s\n", strerror(errno));
- return EXIT_FAILURE;
+ printf("FAIL:Failed to connect to dumpstatez service: %s\n", strerror(errno));
+ return EXIT_SUCCESS;
}
// Set a timeout so that if nothing is read in 10 minutes, we'll stop
@@ -91,7 +91,7 @@
tv.tv_sec = 10 * 60;
tv.tv_usec = 0;
if (setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) == -1) {
- printf("WARNING: Cannot set socket timeout: %s\n", strerror(errno));
+ fprintf(stderr, "WARNING: Cannot set socket timeout: %s\n", strerror(errno));
}
while (1) {
@@ -105,8 +105,7 @@
if (errno == EAGAIN) {
errno = ETIMEDOUT;
}
- printf("\nBugreport read terminated abnormally (%s).\n",
- strerror(errno));
+ printf("FAIL:Bugreport read terminated abnormally (%s)\n", strerror(errno));
break;
}
@@ -117,15 +116,17 @@
write(STDOUT_FILENO, buffer + bytes_read - bytes_to_send,
bytes_to_send));
if (bytes_written == -1) {
- printf(
+ fprintf(stderr,
"Failed to write data to stdout: read %zd, trying to send %zd (%s)\n",
bytes_read, bytes_to_send, strerror(errno));
- return EXIT_FAILURE;
+ break;
}
bytes_to_send -= bytes_written;
} while (bytes_written != 0 && bytes_to_send > 0);
}
- close(s);
+ if (close(s) == -1) {
+ fprintf(stderr, "WARNING: error closing socket: %s\n", strerror(errno));
+ }
return EXIT_SUCCESS;
}