mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-05 08:05:24 +02:00
Apply patch for bug 158786 - remote shell doesnt close after launch
This commit is contained in:
parent
218d051764
commit
47bc4d7548
2 changed files with 35 additions and 4 deletions
|
@ -48,6 +48,8 @@ IHostShellOutputListener {
|
|||
hostShell.exit();
|
||||
notifyAll();
|
||||
try {
|
||||
hostShellInput.close();
|
||||
hostShellError.close();
|
||||
inputStream.close();
|
||||
errorStream.close();
|
||||
outputStream.close();
|
||||
|
@ -56,7 +58,7 @@ IHostShellOutputListener {
|
|||
}
|
||||
}
|
||||
|
||||
public int exitValue() {
|
||||
public synchronized int exitValue() {
|
||||
if(hostShell.isActive())
|
||||
throw new IllegalThreadStateException();
|
||||
// No way to tell what the exit value was.
|
||||
|
@ -76,8 +78,30 @@ IHostShellOutputListener {
|
|||
}
|
||||
|
||||
public synchronized int waitFor() throws InterruptedException {
|
||||
while(hostShell.isActive())
|
||||
wait();
|
||||
|
||||
while(hostShell.isActive()) {
|
||||
try {
|
||||
wait(1000);
|
||||
} catch (InterruptedException e) {
|
||||
// ignore because we're polling to see if shell is still active.
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
// Wait a second to try to get some more output from the target shell before closing.
|
||||
wait(1000);
|
||||
// Allow for the data from the stream to be read if it's available
|
||||
if (inputStream.available() != 0 || errorStream.available() != 0)
|
||||
throw new InterruptedException();
|
||||
|
||||
hostShellInput.close();
|
||||
hostShellError.close();
|
||||
inputStream.close();
|
||||
errorStream.close();
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
// Ignore
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,6 +55,8 @@ public class RemoteRunLaunchDelegate extends AbstractCLaunchDelegate {
|
|||
|
||||
private final static String SHELL_SERVICE = "shell.service"; //$NON-NLS-1$
|
||||
private final static String FILE_SERVICE = "file.service"; //$NON-NLS-1$
|
||||
private final static String EXIT_CMD = "exit"; //$NON-NLS-1$
|
||||
private final static String CMD_DELIMITER = ";"; //$NON-NLS-1$
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
@ -259,8 +261,13 @@ public class RemoteRunLaunchDelegate extends AbstractCLaunchDelegate {
|
|||
|
||||
protected Process remoteShellExec(ILaunchConfiguration config, String remoteCommandPath,
|
||||
String arguments) throws CoreException {
|
||||
String remote_command = arguments == null ? spaceEscapify(remoteCommandPath) :
|
||||
// The exit command is called to force the remote shell to close after our command
|
||||
// is executed. This is to prevent a running process at the end of the debug session.
|
||||
// See Bug 158786.
|
||||
String real_remote_command = arguments == null ? spaceEscapify(remoteCommandPath) :
|
||||
spaceEscapify(remoteCommandPath) + " " + arguments; //$NON-NLS-1$
|
||||
String remote_command = real_remote_command + CMD_DELIMITER + EXIT_CMD;
|
||||
|
||||
IShellService shellService = (IShellService) getConnectedRemoteService(config, SHELL_SERVICE);
|
||||
|
||||
// This is necessary because runCommand does not actually run the command right now.
|
||||
|
|
Loading…
Add table
Reference in a new issue