Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Bug 159803: PTY in console mode on Windows

I started over on Windows 10 64bit and MinGW from nuwen.net. It got a bit bizarre. I created a program (code see below) that reads a character from cin and and prints it, together with endl to cout. I do that continuously in a while loop. As always, this works on an external console and in CDT as expected.

 

Input:

asdf<Enter>

 

Output:

a

s

d

f

 

Now, when I enable winpty in console mode I get the following output with the same input:

fsdf

 

Yes, it is actually starting with an ‘f’ and I don’t get linebreaks. Honestly, I would not have believed that if hadn’t seen it myself. When I terminate the Input with ctrl+z, the program terminates without finishing properly, i.e. output after the while loop is omitted.

 

Here is the code I run. I’d be happy to hear that it contained undefined behavior and that was the reason for my observations.

 

#include <iostream>
using namespace std;

int main() {
    char c;
    while (cin >> c) {
        cout << c << endl;
    }
    cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
    return 0;
}

I’ll give MinGW from mingw.org a try.

 

Regards

Thomas

 

 

 

From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Leherbauer, Anton (Toni)
Sent: Mittwoch, 16. September 2015 08:58
To: CDT General developers list. <cdt-dev@xxxxxxxxxxx>
Subject: Re: [cdt-dev] Bug 159803: PTY in console mode on Windows

 

I just tried again with the C++ hello world including iostream, but it works for me – as long as I specify the correct PATH.

The difference between the C and C++ versions of hello world is that the latter requires 2 mingw DLLs to run.

You could also try building/linking the C++ code with -static-libgcc -static-libstdc++. That makes it a statically linked executable.

I am using the gcc from www.mingw.org.

 

Cheers,

Toni

 

From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Corbat Thomas
Sent: Tuesday, September 15, 2015 5:30 PM
To: CDT General developers list.
Subject: Re: [cdt-dev] Bug 159803: PTY in console mode on Windows

 

I thought of that too. But, then I wouldn’t be able to execute it on console. And it also works if I don’t set the  -Dorg.eclipse.cdt.core.winpty_console_mode=true flag for my child CDT. Furthermore, I figured out that it is only an issue with iostream, but it works with the C hello world example including stdio.

 

I just tried MinGW from nuwen.net (version 5.1). It works neither. Perhaps I need to clean up my PATHs for MinGW.

 

Regards

Thomas

 

From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Leherbauer, Anton (Toni)
Sent: Dienstag, 15. September 2015 16:54
To: CDT General developers list. <
cdt-dev@xxxxxxxxxxx>
Subject: Re: [cdt-dev] Bug 159803: PTY in console mode on Windows

 

Hi Thomas,

 

I assume your program fails to load the DLLs it depends on. You need to add the appropriate PATH in the run config environment.

Did you try running the program without PTY within Eclipse? I’d expect the same failure there as well.

 

Sending EOT before close should work with winpty as well.

 

HTH,

Toni

 

From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Corbat Thomas
Sent: Tuesday, September 15, 2015 4:35 PM
To: CDT General developers list.
Subject: Re: [cdt-dev] Bug 159803: PTY in console mode on Windows

 

Hi Toni

 

Thanks for checking! I’m working on Windows 7 64bit too. It might depend on the compiler or the standard library implementation though. Currently, I use MinGW g++ 4.8.1 from mingw-builds (http://sourceforge.net/projects/mingwbuilds/).

 

My test program was very small: main function with an endless while loop. After checking again I figured out that it depends on whether I have an include to iostream or not. With include to iostream the program crashes (in CDT with PTY, not in an external console). Without that include it works properly, as far as I can tell.

 

I actually wanted to check whether the PTY implementation can cope with sending EOT before closing the stream or not. Unfortunately, I cannot try it with the current behavior of my system. I’ll try another compiler.

 

Kind Regards

Thomas

 

 

From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Leherbauer, Anton (Toni)
Sent: Dienstag, 15. September 2015 09:50
To: CDT General developers list. <
cdt-dev@xxxxxxxxxxx>
Subject: Re: [cdt-dev] Bug 159803: PTY in console mode on Windows

 

Hi Thomas,

 

using winpty in console mode on Windows has always been an experimental feature which can only be enabled with -Dorg.eclipse.cdt.core.winpty_console_mode=true.

Anyway, I just tried it with a hello world project and some other programs. It seems to work for me (Windows 7 64-bit).

Please provide details about the target program, how you build it and on which version of Windows you run it.

 

Thanks,

Toni

 

From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Corbat Thomas
Sent: Monday, September 14, 2015 9:08 AM
To: CDT General developers list. (
cdt-dev@xxxxxxxxxxx)
Subject: [cdt-dev] Bug 159803: PTY in console mode on Windows

 

Hi

 

Marc-AndrĂ© and I are currently investigating the ctrl-D issue (Bug 159803). While trying to figure out whether a possible fix would have some issues on Windows I tried to use the PTY in console mode, explicitly enabled with -Dorg.eclipse.cdt.core.winpty_console_mode=true. This resulted in my target program to terminate immediately, regardless of whether it contained I/O or not.

Has anybody recently used the PTY in console mode on Windows successfully? I remember that the corresponding flag in the run configuration had been disabled on Windows for quite some time (I don’t know whether it had been active at any time at all), so it would have been required to set this explicitly using the system property mentioned above.

 

Any input on that issue is welcome!

 

Regards

Thomas


Back to the top