diff options
| author | 2015-06-07 16:16:15 -0700 | |
|---|---|---|
| committer | 2015-06-07 16:16:15 -0700 | |
| commit | 843b992b51d18c893f3665325ea3045a692832ac (patch) | |
| tree | 3285d2a96a74b8a103007a0c43d5765626178ad1 | |
| parent | 683e3cfef17bb1a80d7c387200ac491e663d5af2 (diff) | |
clean up Process instance after we are done with the sub process
Per java doc of java.lang.Process, #destroy() should be called
after the parent process is done with the sub process.
Bug: 20435160
Change-Id: I254982388c5b46c93c214b37a1e8563f21805e82
| -rw-r--r-- | core/java/android/app/UiAutomationConnection.java | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/core/java/android/app/UiAutomationConnection.java b/core/java/android/app/UiAutomationConnection.java index 9ba6a8ef1267..39cd3bc093b8 100644 --- a/core/java/android/app/UiAutomationConnection.java +++ b/core/java/android/app/UiAutomationConnection.java @@ -239,9 +239,10 @@ public final class UiAutomationConnection extends IUiAutomationConnection.Stub { public void run() { InputStream in = null; OutputStream out = null; + java.lang.Process process = null; try { - java.lang.Process process = Runtime.getRuntime().exec(command); + process = Runtime.getRuntime().exec(command); in = process.getInputStream(); out = new FileOutputStream(sink.getFileDescriptor()); @@ -257,7 +258,9 @@ public final class UiAutomationConnection extends IUiAutomationConnection.Stub { } catch (IOException ioe) { throw new RuntimeException("Error running shell command", ioe); } finally { - IoUtils.closeQuietly(in); + if (process != null) { + process.destroy(); + } IoUtils.closeQuietly(out); IoUtils.closeQuietly(sink); } |