Results 1 to 6 of 6

Thread: properly exiting console application.

  1. #1
    Join Date
    Sep 2013
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows

    Question properly exiting console application.

    Already this is pretty stupid. I haven't done C++ in while so I'm expecting a huge face palm moment here. I can't believe I'm making a post. Anw...

    So I have this insane complexe, multi layered, client server application that goes something like this :

    Qt Code:
    1. #include <iostream>
    2.  
    3. int main()
    4. {
    5. std::cout << "I AM A BONANA!" << std::endl;
    6. return 0;
    7. }
    To copy to clipboard, switch view to plain text mode 

    no includes, no nothing. Did you get the sarcasm there?

    1. click RUN
    2. I giggle
    2. I see this message "Press <RETURN> to close this window..." and I'm thinking "Good at least I don't have to _getch() at the end of every console application"
    3. Pressed <RETURN>
    4. Console closes.
    5. QT Environment's application output says : "Cannot obtain a handle to the inferior: The parameter is incorrect."
    6. Like any good programer who doesn't know what to do I just find the nearest X to close the tab
    7. Pop up window says "Application is still running. Force it to quit?" with a "Force Quit" button and a "Keep Running" button.
    7.1. ????????????? WHY YOU NO CLOSED!?

    So a added a break-point and launched the debugger. Guess what. I didn't get the application output message or the pop up window!

    So I tried :

    Qt Code:
    1. #include <iostream>
    2. #include <cstdlib>
    3.  
    4. int main()
    5. {
    6. std::cout << "I AM A BONANA!" << std::endl;
    7. std::exit(0);
    8. }
    To copy to clipboard, switch view to plain text mode 

    aaaaaand it's still the same...

    PLease help. I promissss I'll be your bestest friend!

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: properly exiting console application.

    There is nothing wrong with your program, either version should exit right after printing the output.

    Maybe you accidentally ran the program in the debugger and the debugger had not exited yet?

    Cheers,
    _

  3. #3
    Join Date
    Sep 2013
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: properly exiting console application.

    I'm pretty sure I'm not using the debugger since I am using ctrl+R to run. I tried it by explicitly clicking the button and it doesn't work either. When I restarted my computer it worked 1 time and then it started doing the same thing. I'll try reinstalling qt tonight and see what happens.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: properly exiting console application.

    It is definitely not your program that is at fault.
    It has ended otherwise you wouldn't see "Press <RETURN> to close this window..."

    Now, whatever creates that window might not have exited. I wouldn't worry about that too much though.

    Cheers,
    _

  5. #5
    Join Date
    Sep 2013
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: properly exiting console application.

    I went through the trouble of uninstalling, getting the latest version online (again) and reinstalling. Still no change. I tried cleaning before running, deleting the .pro.user file, the folder with the makefile... well basically anything except the code.

    I read online that people have had similar problem, they can compile there code with different compilers and run it normally. I found that, under Projects side tab -> run, if I uncheck "Run in terminal" I don't get the error. It's kind of like when I run with the terminal, without the debugger. QTCreator does not realize that when the process is over or something like that.

    Kinda makes sens considering the error message I get : "Cannot obtain a handle to the inferior: The parameter is incorrect."

    Somewhere, when launching the code with the terminal and expected handler isn't returned or something. I'm just guessing. Anw... could this be a bug?

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: properly exiting console application.

    7. Pop up window says "Application is still running. Force it to quit?" with a "Force Quit" button and a "Keep Running" button.
    7.1. ????????????? WHY YOU NO CLOSED!?
    Your application has terminated. The stub program that Qt Creator has run along with your program in order to connect its output with the Windows console window and wait for a key press is still running... it is waiting for you to "Press <RETURN> to close this window...". The process is called qtcreator_stub_process.exe (or the like) and is prominently visible in the console window title bar and task manager.

    On my Windows XP box with an ancient Creator the stub process closes cleanly when you press Return. It may be a quirk of your OS version or Creator version that causes it to hang rather than close. In any case, it should not have any negative effect on your application which is long since terminated.

    If your program does not require user console input then running without the console window is a viable option: output is visible in the "Application Output" pane in Creator.

Similar Threads

  1. Replies: 2
    Last Post: 28th July 2013, 09:59
  2. Replies: 0
    Last Post: 3rd May 2012, 22:38
  3. Replies: 1
    Last Post: 13th September 2011, 09:56
  4. Replies: 2
    Last Post: 7th July 2011, 10:20
  5. Exiting a Qt Console Application
    By nbetcher in forum Qt Programming
    Replies: 4
    Last Post: 23rd March 2009, 21:03

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.