Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 158788
Collapse All | Expand All

(-)src/org/eclipse/rse/remotecdt/RemoteRunLaunchDelegate.java (-1 / +8 lines)
Lines 55-60 Link Here
55
	
55
	
56
	private final static String SHELL_SERVICE = "shell.service";  //$NON-NLS-1$
56
	private final static String SHELL_SERVICE = "shell.service";  //$NON-NLS-1$
57
	private final static String FILE_SERVICE = "file.service";  //$NON-NLS-1$
57
	private final static String FILE_SERVICE = "file.service";  //$NON-NLS-1$
58
	private final static String EXIT_CMD = "exit"; //$NON-NLS-1$
59
	private final static String CMD_DELIMITER = ";"; //$NON-NLS-1$
58
	
60
	
59
	/*
61
	/*
60
	 *  (non-Javadoc)
62
	 *  (non-Javadoc)
Lines 259-266 Link Here
259
	
261
	
260
	protected Process remoteShellExec(ILaunchConfiguration config, String remoteCommandPath,
262
	protected Process remoteShellExec(ILaunchConfiguration config, String remoteCommandPath,
261
			String arguments) throws CoreException {
263
			String arguments) throws CoreException {
262
		String remote_command = arguments == null ? spaceEscapify(remoteCommandPath) :
264
		// The exit command is called to force the remote shell to close after our command 
265
		// is executed. This is to prevent a running process at the end of the debug session.
266
		// See Bug 158786.
267
		String real_remote_command = arguments == null ? spaceEscapify(remoteCommandPath) :
263
												    spaceEscapify(remoteCommandPath) + " " + arguments; //$NON-NLS-1$
268
												    spaceEscapify(remoteCommandPath) + " " + arguments; //$NON-NLS-1$
269
		String remote_command = real_remote_command + CMD_DELIMITER + EXIT_CMD;
270
		
264
		IShellService shellService = (IShellService) getConnectedRemoteService(config, SHELL_SERVICE);
271
		IShellService shellService = (IShellService) getConnectedRemoteService(config, SHELL_SERVICE);
265
		
272
		
266
		// This is necessary because runCommand does not actually run the command right now.
273
		// This is necessary because runCommand does not actually run the command right now.
(-)src/org/eclipse/rse/remotecdt/HostShellAdapter.java (-3 / +27 lines)
Lines 48-53 Link Here
48
		hostShell.exit();
48
		hostShell.exit();
49
		notifyAll();
49
		notifyAll();
50
		try {
50
		try {
51
			hostShellInput.close();
52
			hostShellError.close();
51
			inputStream.close();
53
			inputStream.close();
52
			errorStream.close();
54
			errorStream.close();
53
			outputStream.close();
55
			outputStream.close();
Lines 56-62 Link Here
56
		}	
58
		}	
57
	}
59
	}
58
60
59
	public int exitValue() {
61
	public synchronized int exitValue() {
60
		if(hostShell.isActive())
62
		if(hostShell.isActive())
61
			throw new IllegalThreadStateException();
63
			throw new IllegalThreadStateException();
62
		// No way to tell what the exit value was.
64
		// No way to tell what the exit value was.
Lines 76-83 Link Here
76
	}
78
	}
77
79
78
	public synchronized int waitFor() throws InterruptedException {
80
	public synchronized int waitFor() throws InterruptedException {
79
		while(hostShell.isActive())
81
		
80
			wait();
82
		while(hostShell.isActive()) {
83
			try {
84
				wait(1000);
85
			} catch (InterruptedException e) {
86
				// ignore because we're polling to see if shell is still active.
87
			}
88
		}
89
		
90
		try {
91
			// Wait a second to try to get some more output from the target shell before closing.
92
			wait(1000);
93
			// Allow for the data from the stream to be read if it's available
94
			if (inputStream.available() != 0 || errorStream.available() != 0)
95
				throw new InterruptedException();
96
	
97
			hostShellInput.close();
98
			hostShellError.close();
99
			inputStream.close();
100
			errorStream.close();
101
			outputStream.close();
102
		} catch (IOException e) {
103
			// Ignore
104
		}
81
		return 0;
105
		return 0;
82
	}
106
	}
83
	
107
	

Return to bug 158788