From b2502802c4b488efe62bd0e8eba0a3d6cc4bdd50 Mon Sep 17 00:00:00 2001 From: Sorin Basca Date: Wed, 21 Feb 2024 11:17:27 +0000 Subject: Handle stream closed when task process exits Fixes: 308917607 Test: art/tools/run-libcore-tests.sh --mode=host --gcstress Change-Id: Iac16e028d6fc1f247948357c5f686bbf2cb25b91 --- src/vogar/monitor/InterleavedReader.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/vogar/monitor/InterleavedReader.java b/src/vogar/monitor/InterleavedReader.java index 2f9f15a..a97ba56 100644 --- a/src/vogar/monitor/InterleavedReader.java +++ b/src/vogar/monitor/InterleavedReader.java @@ -78,7 +78,15 @@ public final class InterleavedReader implements Closeable { int textEnd; while (true) { - int r = reader.read(buffer, count, buffer.length - count); + int r = -1; + + try { + r = reader.read(buffer, count, buffer.length - count); + } catch (IOException e) { + // When running under gcstress, the output stream may be closed outside our control when + // the target process exits. In order to allow this, catch the stream closed exception and + // return whatever has been buffered already. (b/308917607) + } if (r == -1) { // the input is exhausted; return the remaining characters -- cgit v1.2.3