1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 18:26:01 +02:00

Bug 333613 - [terminal] "Job found still running" message on stdout console after terminating Eclipse

This commit is contained in:
Martin Oberhuber 2011-03-14 23:56:35 +00:00
parent 1f554a098f
commit 0471c93f0a
2 changed files with 40 additions and 22 deletions

View file

@ -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] Avoid "Job still found running" error after shutdown
*******************************************************************************/
package org.eclipse.tm.internal.terminal.emulator;
@ -345,12 +346,6 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
public void disconnectTerminal() {
Logger.log("entered."); //$NON-NLS-1$
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.
@ -361,10 +356,24 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
}
if (job!=null) {
job.cancel();
// Join job to avoid leaving job running after workbench shutdown (333613).
try {
fInputStream.close();
//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();
job.join();
} catch (IOException e1) {
} catch (InterruptedException e) {
}
}
if (getState()==TerminalState.CLOSED) {
return;
}
if(getTerminalConnector()!=null) {
getTerminalConnector().disconnect();
}
}

View file

@ -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] Avoid "Job still found running" error after shutdown
*******************************************************************************/
package org.eclipse.tm.internal.terminal.textcanvas;
@ -72,7 +73,12 @@ public class PipedInputStream extends InputStream {
* Must be called with a lock on this!
*/
public int available() {
if (fUsedSlots > 0) {
return fUsedSlots;
} else if (fClosed) {
return -1;
}
return 0;
}
/**
* Writes a single byte to the buffer. Blocks if the buffer is full.
@ -237,7 +243,8 @@ public class PipedInputStream extends InputStream {
}
/**
* 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. Returns <code>-1<code> if
* stream is closed and no characters are left in pipe.
*/
public int available() {
synchronized(fQueue) {
@ -259,12 +266,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 {