diff options
author | Martin Oberhuber | 2011-05-24 11:38:36 +0000 |
---|---|---|
committer | Martin Oberhuber | 2011-05-24 11:38:36 +0000 |
commit | 6574e97d09242f470b519701795d0fc96b1d163d (patch) | |
tree | be8f3800ff8c1241dcb3f8a28e5a4c0ae46bb6dd /terminal | |
parent | 204feee74ecd4755cf7a5d2775863907aecc9b8b (diff) | |
download | org.eclipse.tm-6574e97d09242f470b519701795d0fc96b1d163d.tar.gz org.eclipse.tm-6574e97d09242f470b519701795d0fc96b1d163d.tar.xz org.eclipse.tm-6574e97d09242f470b519701795d0fc96b1d163d.zip |
Bug 346968 - [terminal] Backport to 3.2.x: "Job found still running" message on stdout console after terminating Eclipse
Diffstat (limited to 'terminal')
2 files changed, 33 insertions, 23 deletions
diff --git a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java index 18ff1ffd2..773d05aa3 100644 --- a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java +++ b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java @@ -26,6 +26,7 @@ * Martin Oberhuber (Wind River) - [240745] Pressing Ctrl+F1 in the Terminal should bring up context help * Michael Scharf (Wind River) - [240098] The cursor should not blink when the terminal is disconnected * Anton Leherbauer (Wind River) - [335021] Middle mouse button copy/paste does not work with the terminal + * Pawel Piech (Wind River) - [333613] "Job found still running" after shutdown *******************************************************************************/ package org.eclipse.tm.internal.terminal.emulator; @@ -345,27 +346,33 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC public void disconnectTerminal() { Logger.log("entered."); //$NON-NLS-1$ + //Ensure that a new Job can be started; then clean up old Job. + //TODO not sure whether the fInputStream needs to be cleaned too, + //or whether the Job could actually cancel in case the fInputStream is closed. + Job job; + synchronized(this) { + job = fJob; + fJob = null; + } + if (job!=null) { + job.cancel(); + // Join job to avoid leaving job running after workbench shutdown (333613). + try { + fInputStream.close(); + job.join(); + } catch (IOException e1) { + } catch (InterruptedException e) { + } +// Thread t = job.getThread(); +// if(t!=null) t.interrupt(); + } + if (getState()==TerminalState.CLOSED) { return; } if(getTerminalConnector()!=null) { getTerminalConnector().disconnect(); } - //Ensure that a new Job can be started; then clean up old Job. - //TODO not sure whether the fInputStream needs to be cleaned too, - //or whether the Job could actually cancel in case the fInputStream is closed. - Job job; - synchronized(this) { - job = fJob; - fJob = null; - } - if (job!=null) { - job.cancel(); - //There's not really a need to interrupt, since the job will - //check its cancel status after 500 msec latest anyways... - //Thread t = job.getThread(); - //if(t!=null) t.interrupt(); - } } // TODO diff --git a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/PipedInputStream.java b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/PipedInputStream.java index 5b36e5a9b..f0e11324a 100644 --- a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/PipedInputStream.java +++ b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/PipedInputStream.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 1996, 2008 Wind River Systems, Inc. and others. + * Copyright (c) 1996, 2011 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,6 +10,7 @@ * Douglas Lea (Addison Wesley) - [cq:1552] BoundedBufferWithStateTracking adapted to BoundedByteBuffer * Martin Oberhuber (Wind River) - the waitForAvailable method * Martin Oberhuber (Wind River) - [208166] Avoid unnecessary arraycopy in BoundedByteBuffer + * Pawel Piech (Wind River) - [333613] "Job found still running" after shutdown *******************************************************************************/ package org.eclipse.tm.internal.terminal.textcanvas; @@ -72,7 +73,7 @@ public class PipedInputStream extends InputStream { * Must be called with a lock on this! */ public int available() { - return fUsedSlots; + return fUsedSlots; } /** * Writes a single byte to the buffer. Blocks if the buffer is full. @@ -231,13 +232,13 @@ public class PipedInputStream extends InputStream { */ public void waitForAvailable(long millis) throws InterruptedException { synchronized(fQueue) { - if(fQueue.available()==0) + if(fQueue.available()==0 && !fQueue.fClosed) fQueue.wait(millis); } } /** * Must be called in the Display Thread! - * @return true if a character is available for the terminal to show. + * @return number of characters available for reading. */ public int available() { synchronized(fQueue) { @@ -259,12 +260,14 @@ public class PipedInputStream extends InputStream { } } /** - * Closing a <tt>PipedInputStream</tt> has no effect. The methods in - * this class can be called after the stream has been closed without - * generating an <tt>IOException</tt>. - * <p> + * Closing a <tt>PipedInputStream</tt> is the same as closing the output stream. + * The stream will allow reading data that's still in the pipe after which it will + * throw an <tt>IOException</tt>. */ public void close() throws IOException { + synchronized(fQueue) { + fQueue.close(); + } } public int read(byte[] cbuf, int off, int len) throws IOException { |