Do not fail if the tombstoned output fd is a socket or pipe.
Test: adb bugreport; check the produced report
Bug: 131636651
Bug: 130025619
Change-Id: Id346d6e2bce313473190538505f2f071cdc54df5
diff --git a/libartpalette/system/palette_android.cc b/libartpalette/system/palette_android.cc
index 9c35d93..2314f30 100644
--- a/libartpalette/system/palette_android.cc
+++ b/libartpalette/system/palette_android.cc
@@ -117,7 +117,9 @@
if (!android::base::WriteFully(output_fd, msg, msg_len)) {
PLOG(ERROR) << "Failed to write tombstoned output";
success = false;
- } else if (TEMP_FAILURE_RETRY(fsync(output_fd)) == -1) {
+ } else if (TEMP_FAILURE_RETRY(fsync(output_fd)) == -1 && errno != EINVAL) {
+ // Ignore EINVAL so we don't report failure if we just tried to flush a pipe
+ // or socket.
PLOG(ERROR) << "Failed to fsync tombstoned output";
success = false;
} else if (close(output_fd.release()) == -1) {