Community
Participate
Working Groups
When I start a remote debugging session the session has four processes: - gdbserver debugger - Remote Shell - gdb - executable After the debugged application terminates the gdbserver, gdb and executable are flagged as terminated as it should be. The Remote Shell remains alive. It still has a console attached and I can enter commands on it's command line. When I type "exit" the shell exits, but the status is not reflected in the debug view. I have to manually kill the Remote Shell in the debug view. (Works but is ugly) Leaving a shell connection open is in my opinion pretty bad behavior so for now I'll say that this is a "major" bug. -----------Enter bugs above this line----------- RSE 1.0 Testing round 1 installation : eclipse-platform-3.2.0 (M20060629-1905), cdt-3.1.0 RSE install : update-site RSE-complete java.runtime : Java(TM) 2 Runtime Environment, Standard Edition java.runtime.version=1.5.0_06-b05 os.name: : Windows XP 5.1, Service Pack 2 ------------------------------------------------ systemtype : ssh only targetos : LSB_VERSION="core-2.0-noarch:core-3.0-noarch:core-2.0-ia32:core-3.0-ia32" SUSE LINUX 10.0 (i586) VERSION = 10.0 targetuname : Linux nb14520d 2.6.13-15-smp #1 SMP Tue Sep 13 14:56:15 UTC 2005 i686 i686 i386 GNU/Linux targetvm : java version "1.4.2_06" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_06-b03) Java HotSpot(TM) Client VM (build 1.4.2_06-b03, mixed mode) ------------------------------------------------
Hi, I've documented this as a limitation in the plugin (org.eclipse.rse.remotecdt/instructions.txt). The problem is that I have no way to detect that the user command in the remote shell has completed. From what I can tell, I can only open a remote shell, and pass commands to it. I cannot just run one command to completion on the remote target. I can hack it for the debug case to terminate when I detect that the gdb connection has terminated but I have no way to know for the run case that the user program has stopped running. For now I think this should be marked as a limitation. I will file a bug against the RSE APIs and fix this later when that bug is resolved. Thanks.
DaveM... I'm wondering whether Ewa could to this: * Start the debuggee with "exec" --> replace the Shell process by the Debuggee * Listen to the Output and Error Streams * If the Streams are closed, the debuggee has terminated I believe that's how the RSE command view detects that the remote shell has terminated - when user types "exit" the command view is marked as "terminated". Another option would be to call the debuggee like this: $command ; exit Such that the shell runs the debuggee command, and as soon as the debuggee command is finished, it performs an "exit", leading the output and error streams to close. Ideas or Comments?
Is "exit" a command that is recognized by every kind of shell subsystem? I can give this method a try very easily.
The "$command ; exit" approach might work. See what happens with that.
All the shells I know of have an "exit" command: Bourne sh, ksh, csh, tcsh, zsh, bash, and cmd. The only difference is that Unixy flavors of shells use ";" as separator while Windows cmd uses "&" as separator. But there's a method on the IRemoteCmdSubSystem.getCommandSeparator() which returns exactly the separator to use. Since the "Universal" subsystems that we are dealing with are kind of Unix Flavor anyways, I think we should be OK with the limitation. Moreover, in case a remote shell should not support the "exit" command, the worst thing that can happen is that the shell remains open... which doesnt seem too bad.
I try to write a custom launcher for us using RSE and I have the same problem. The shell stays open and if I close it manually I get the following error: Error logged from Debug Core: java.io.IOException: Pipe broken at java.io.PipedInputStream.read(PipedInputStream.java:255) at java.io.PipedInputStream.read(PipedInputStream.java:305) at java.io.BufferedInputStream.read1(BufferedInputStream.java:254) at java.io.BufferedInputStream.read(BufferedInputStream.java:313) at java.io.FilterInputStream.read(FilterInputStream.java:90) at org.eclipse.debug.internal.core.OutputStreamMonitor.read(OutputStreamMonitor.java:138) at org.eclipse.debug.internal.core.OutputStreamMonitor.access$1 (OutputStreamMonitor.java:128) at org.eclipse.debug.internal.core.OutputStreamMonitor$1.run(OutputStreamMonitor.java:194) at java.lang.Thread.run(Thread.java:595) This is a code snippet of what I tried. I tried both methods (launchShell+writeToShell and runCommand). The workaround with coomad + ";exit" fails completely with runCommand and with launchShell+writeToShell I still get the error with the exception above. This workaround would not work for me (in our final product), as I do not want to expose that kind of error to the user. IShellService shellService = (IShellService) getConnectedRemoteService( configuration, SHELL_SERVICE); String [] environment = new String[2]; environment[0] = "AAA=BBB"; environment[1] = "ZZZ=YYY"; String initialWorkingDirectory = ""; String command = "ls"; // IHostShell hostShell = shellService.launchShell(monitor, initialWorkingDirectory, environment); // hostShell.writeToShell(command); IHostShell hostShell = shellService.runCommand(monitor, initialWorkingDirectory, command, environment); try { remoteProcess = new HostShellAdapter(hostShell); } catch (Exception e) { if (remoteProcess != null) { remoteProcess.destroy(); } throw new CoreException( new Status( IStatus.ERROR, DebugPlugin.PLUGIN_ID, IStatus.OK, Messages .getString("EngineLaunchConfigurationDelegate.createprocessfailed"), //$NON-NLS-1$ null)); } IProcess process = org.eclipse.debug.core.DebugPlugin.newProcess(launch, remoteProcess, "just a test");
I changed the HostShellAdapter so that I get prints in the destroy() and exitValue() calls like this: public synchronized void destroy() { System.out.println("destroy()"); hostShell.exit(); System.out.println("after exit()"); notifyAll(); try { inputStream.close(); errorStream.close(); outputStream.close(); } catch (IOException e) { // Ignore } } public int exitValue() { boolean isActive = hostShell.isActive(); System.out.println("isActive=" + isActive); if(isActive) throw new IllegalThreadStateException(); // No way to tell what the exit value was. return 0; } This is what I get when I call the shell with "ls;exit": The java.io.IOException is due to the fact that the shell already has called exit. What's strange however is that the shell claims still that it's active. And then I get a "Terminate failed" messagebox. destroy() java.io.IOException: Broken pipe after exit() isActive=true isActive=true isActive=true isActive=true isActive=true isActive=true isActive=true isActive=true isActive=true isActive=true isActive=true
I forgot to say that I tried to use the Local connection on a Linux machine. I did not try any real remote connection, as it doesn't even work with Local.
I tried now with a ssh connection to my local machine and this is what I get: The shell executes exit (logout), but the process is still shown as running. If I terminate I get the following log: isActive=true destroy() after exit() isActive=false isActive=false So the remote shell reports isActive correctly (only Local does it wrong) But even with the "command;exit" workaround the eclipse process does not terminate automatically. What can I do to get the process terminated one the command exits?
shellService.runCommand does not work with ssh; it works with Local though. I tried it also with WindowsXP (dstore) and it works there, too. Just the output is a bit funny DataElement { Type: command Name: dir Value: dir ID: 826407830 Source: Depth: 2 DataStore: 172.16.92.128 } DataElement { Type: stdout Name: Value: ID: -1734739135 Source: Depth: 2 DataStore: 172.16.92.128 } DataElement { Type: stdout Name: Volume in drive C has no label. Value: Volume in drive C has no label. ID: 1348701698 Source: Depth: 2 DataStore: 172.16.92.128 } ... Should I open a separate bug for that?
Hi, I'm attaching a patch for this bug. I had the same problem where the terminal shell was not exiting with the ssh connection even with the exit command. To fix this I had to modify HostShellAdapter as described in the patch. The problem was the that the waitForExit was not polling the isActive command because of course in the past it would always be active without the exit command. With the patch, the remote shell process. exits when the process exits. Regarding your problems with the runCommand sometimes being implemented, that's a bug with the RSE API's. It should be filed as a separate bug. Regarding the exception you're seeing with the Local connection, I've never seen this but I'll give it a try. Regarding the weird output from the dstore connection, yes please file a bug. I have the same problem with the Remote C/C++ Launcher. At least maybe the implementor can justify why it has to look like that. Thank You, Ewa
Reopening untim Martin merges the patch.
Thanks Ewa, I'll try it as soon as it get's available. By the way, would it be possible to move the HostShellAdapter into another rse package? I did copy it into my project, as I don't want a dependency to CDT. I will open new bugs for the weird output from the dstore connection and the runCommand sometimes being implemented.
Created attachment 52422 [details] Patch to close the Remote Shell process. Moving Ewa's patch from bug 158788 where it had accidentally been stored to the right bug
Whoops...I had a late night last night. Thanks for catching that Martin.
(In reply to comment #13) > By the way, would it be possible to move the HostShellAdapter into another rse > package? I did copy it into my project, as I don't want a dependency to CDT. Applied the patch, it should be in RSE 1.0 RC2. Marking this bug fixed, since the other observations are tracked separately: Bug 161770 (runCommand fails with ssh) Bug 161773 (strange output with dstore) Bug 161777 (move HostShellOutputAdapter)
I can confirm that the fix works for SSH, Windows dstore in RSE 1.0RC2. Local still fails, due to the isActive problem described in comment 7. https://bugs.eclipse.org/bugs/show_bug.cgi?id=158786#c7 I'm going to open a seperate bug for that problem.
Thanks. If you verify a bug, feel free to set status "VERIFIED". This helps us to know that a user (reporter) actually verified it. We will then set it CLOSED once we've verified it as well.
Closing.
[target cleanup] 1.0 RC2 was the original target milestone for this bug