Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 314625

Summary: [terminal][local] Local Terminal sometimes doesn't display a prompt on Linux
Product: [Tools] Target Management Reporter: Martin Oberhuber <mober.at+eclipse>
Component: TerminalAssignee: dsdp.tm.core-inbox <tm.core-inbox>
Status: RESOLVED WONTFIX QA Contact: Martin Oberhuber <mober.at+eclipse>
Severity: normal    
Priority: P3 CC: eclipse, mirko, uwe.st
Version: 3.2   
Target Milestone: ---   
Hardware: PC   
OS: Linux-GTK   
Whiteboard:

Description Martin Oberhuber CLA 2010-05-27 05:23:04 EDT
Build ID: Workspace HEAD of 27-May-2010 on eclipse-3.6rc2 on Linux-GTK-RHEL4

I'm launching a local terminal on my default /bin/tcsh shell. On the configuration's "common" tab, I have disabled "Allocate Console".

The terminal works nicely, I can also use vi for editing and resize as needed. But on the shell commandline, after showing output of a command the shell's prompt sometimes does not appear. For instance, I typed 
   env | grep -i term
and it showed output but no prompt.

I see this happening about once per 10 commands. Mostly when entering a new command the first time (also on "ls" and the like). I have never seen this happen on the telnet or ssh Terminals. It looks like the PTY solution is lacking some kind of flush / flow control, or some intermediate Stream is buffered where it should not be buffered.

Workaround: Just press ENTER to get the prompt. It's not really a big deal, but it does affect my trust in the tool.
Comment 1 Martin Oberhuber CLA 2010-05-27 06:17:23 EDT
In one case, it even happened to me that when initially connecting / launching the Terminal, no output or prompt was shown. Probably related to a race condition with multiple open Local Terminals and opening a Console at the same time (see
bug 314607).

Which makes this even more nasty.
Comment 2 Mirko Raner CLA 2010-05-28 03:14:31 EDT
(In reply to comment #1)
> Probably related to a race
> condition with multiple open Local Terminals and opening a Console at the same
> time (see
> bug 314607).

It looks like your suspicion is spot on, at least when this happens at the very beginning of a terminal session it seems to be indeed a side effect of bug 314607. When I debugged through the variable contents for the stack trace from bug 314607 comment #6 I noticed that the string that was written to IOConsoleOutputStream.write(String) was actually my "bash-3.2$" prompt. Clearly, this should have already been intercepted and sent to the terminal instead. I'll investigate why it was still sent to the regular console.

When the missing prompt problem occurs after the session is already established I think you are correct that there is a second, partially overlapping issue that has to do with the PTY flushing. It may also have to do with the coordination of stdout versus stderr (the prompt is actually sent to stderr, at least for bash).
Comment 3 Martin Oberhuber CLA 2010-05-28 05:07:24 EDT
(In reply to comment #2)
> coordination of stdout versus stderr (the prompt is actually sent to
> stderr, at least for bash).

Interesting, this is in line with another observation I made: As part of my experiements on Windows, I created a Launch to call the following "program":

  Location  = C:/Program Files/TortoiseSVN/bin/TortoisePlink.exe
  Arguments = -l moberhuber -i "D:/home/.ssh/id_dsa.ppk" build.eclipse.org

The idea here was along the lines of what I documented in bug 314827. The connection itself worked, although running vi on the remote or terminal resizing failed (since don't have a proper Windows PTY, as per bug 314193 comment 2; but what I found interesting was that in this experiment, I saw each prompt being printed twice. Probably that was one for stdout and the other for stderr.
Comment 4 Uwe Stieber CLA 2015-05-06 05:00:50 EDT
Implementation replaced