[UPDATED] "GDB: Failed to set controlling terminal: Invalid argument." -- I do not get any output into a terminal.



  • Hello,

    I am running Qt Creator 2.1 (installed from repository) on Ubuntu 11.04.

    When I start debugging I get this message "GDB: Failed to set controlling terminal: Invalid argument."

    I did search and found it did not affect anyone's functionality, however I do not get any output. It completely ignores printf() and cout.

    I tried to output to both Application Output and XTerm.

    How do I fix it?

    THX!!



  • The message as such is Mostly Harmless.

    Do you flush your output (i.e. use std::flush or std::endl somewhere)?

    Do you have "Run in Terminal" checked?

    Does the problem persist if you use std::cerr instead of std::cout?



  • Ah, endl does help both in Application Output and in terminal.

    Strangely, cerr just works w/o flushing.

    How to flush with printf()?

    Thank you!! It is certainly a bug.



  • [quote author="vincegata" date="1309381341"]Ah, endl does help both in Application Output and in terminal.
    Strangely, cerr just works w/o flushing.
    [/quote]

    Because cerr is unbuffered by default. It basically flushes after each operation.

    [quote author="vincegata" date="1309381341"]
    How to flush with printf()?
    [/quote]

    By e.g. using fflush(stdout)

    [quote author="vincegata" date="1309381341"]
    Thank you!! It is certainly a bug.[/quote]

    Indeed. Not flushing the streams when required is certainly a bug in your application.



  • I've just run this just to make sure (I new it would run) in Code::Blocks

    int main()
    {
    cout << "Hello\n";
    cout << "Hello\n";
    cout << "Hello\n";
    cout << "Hello\n";
    cout << "Hello\n";
    return 0;
    }

    and I received the output as expected. I bet if I run it in Eclipse I would get an output. I do not remember having such issue with VC++ either. It's the Qt Creator's problem b/c it's throwing that error.



  • Buffering is not a bug, it's a feature. And about the message, yes that's a bug, but a harmless one (it doesn't have to do anything with the buffering of the output). If you don't like buffers, you can always disable buffering (just ask google on how to), but you'll have to live with eventual performance problems, if you write heavily to stdout.



  • The "GDB: Failed to set controlling terminal" message comes directly from gdb, this is only displayed by Qt Creator as-is.



  • Yes, I have the same warning, but it does not affect debugging. I assume that it will be fixed either in the new version of Qt Creator, or maybe an update to gdb. (The problem is that Qt creator is using a pseudoterminal to control gdb, but Qt Creator either doesn't set the correct options, and/or gdb doesn't detect that it's running in a pseudoterminal).



  • What would the correct options be?



  • I don't know and I'm sure it's not that easy. Also the "bug report":http://bugreports.qt.nokia.com/browse/QTCREATORBUG-3918 on this topic has been ruled "out of scope".



  • I don't know if anyone is still reading this thread, but...I just came across the problem myself. A couple of factoids you might find helpful:

    1. this message only displays if you have disabled "Run in terminal" from the Run Settings. I have a feeling that it pertains to Creator's inability to accept input from a program. As others have said, it doesn't seem to affect debugging.

    2. When one does select "Run in terminal," that's where the fun starts. The default setting for the System Terminal is "xterm -e" but according to my terminal output, there is no such option for xterm. When you use "xterm" nothing seems to happen; the debugger starts and ends without hitting any breakpoints in the program, and nothing seems to execute. When you use "gnome-terminal" you get a terminal window, but the program hangs until you close the window, and nothing seems to execute. There seems to be some issue with the application talking through the terminal.

    Some other forums have conflicting information about this problem, but if anyone knows of a workaround for this, it would be very helpful. Thanks.



  • [quote author="mzimmers" date="1332532447"]

    1. When one does select "Run in terminal," that's where the fun starts. The default setting for the System Terminal is "xterm -e" but according to my terminal output, there is no such option for xterm. When you use "xterm" nothing seems to happen; the debugger starts and ends without hitting any breakpoints in the program, and nothing seems to execute. When you use "gnome-terminal" you get a terminal window, but the program hangs until you close the window, and nothing seems to execute. There seems to be some issue with the application talking through the terminal.

    Some other forums have conflicting information about this problem, but if anyone knows of a workaround for this, it would be very helpful. Thanks.[/quote]

    There is no workaround, it's a bug and it's filed. If you find a workaround please post. I do not like squinting at xterm myself, it doesn't have copy&paste either.

    http://qt-project.org/forums/viewthread/13892/



  • Hello,

    I am not sure if this ill behavior is related to the posted error message "GDB: Failed to set controlling...", but I decided to post it here because I would think they are related. I am sure it can be demonstrated with simpler code but it is what I have.

    If you run this app in bash it will run correctly: every 2 seconds you will see a randomly generated number and its index in a vector. If you type the index that has already been shown it will output that random number multiplied by ten.

    If you run this app under debugger in Qt Creator then the getline() function in main thread (in Run() function) will start reading the output of its own process, it will read the output of "my_err(" ****** starting process... ****** ");" statement -- totally incorrect behavior. If you run the app from command line getline() will stuck and wait for the user input.

    The bottom line is that getline() reads the stdout of its own process when you run an app under debugger. Any thoughts on this? Anybody else have experienced it?

    I am on Ubuntu.

    P.S. I tried to post the code but it's complaining about the size must be less than 6000 chars. I'll PM to those interested.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.