Results 1 to 3 of 3

Thread: QProcess exitStatus()

  1. #1
    Join Date
    Jan 2007
    Posts
    92
    Thanks
    14
    Thanked 1 Time in 1 Post

    Default QProcess exitStatus()

    Hi Guys,
    I have question about QProcess exitStatus() method. I am using QProcess to communicate with external program bash script. The bash script gives me return code of either 0,2 or 3. Now I want to test some conditions based on qprocess output. Once processExited() signal triggers it will connect to processDone() slot. Can QProcess returns the exit code of any digit other than 0. I noticed when my script gives me exit code of 2 or 3..I get crash as soon as processDone() get called. It looks like I can not verify the exit status of Qprocess other than using digit 0. I could have used readLineStdOut( ) to read output value but I dont want to get returned string value. How do I get exit status if return code from external program is numeric digit other than just 0.

    I am using Qt3.


    Qt Code:
    1. connect ( myProcess , SIGNAL ( processExited()) , this , SLOT ( processDone ( ) ) );
    2.  
    3. void MainWindow::processDone()
    4. {
    5. if ( myProcess->exitStatus() == 0)
    6. {
    7. qDebug () << "Program ran successfully";
    8. }
    9. if ( myProcess->exitStatus() == 2)
    10. {
    11. qDebug () << "Customized message";
    12. }
    13.  
    14. if ( myProcess->exitStatus() == 3)
    15. {
    16. qDebug () << "Another text warning message";
    17. }
    18.  
    19. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QProcess exitStatus()

    If you get a crash, it is most likely caused by myProcess being an invalid pointer or something like that. Use a debugger to determine where exactly the crash occurs.

  3. The following user says thank you to wysota for this useful post:

    user_mail07 (12th June 2008)

  4. #3
    Join Date
    Jan 2007
    Posts
    92
    Thanks
    14
    Thanked 1 Time in 1 Post

    Default Re: QProcess exitStatus()

    I solved my problem. Actually there was not a problem with Qprocess or exitStatus( ). exitStatus() can return any integer value. After checking the exitStatus of QProcess, I was not intializing the pointer to object properly.

Similar Threads

  1. Replies: 2
    Last Post: 2nd June 2008, 08:45
  2. QProcess and Pipes
    By KaptainKarl in forum Qt Programming
    Replies: 1
    Last Post: 9th April 2007, 23:11
  3. QProcess extremely slow on Windows?
    By Pepe in forum Qt Programming
    Replies: 2
    Last Post: 26th March 2007, 00:25
  4. problem with qprocess
    By deekayt in forum Qt Programming
    Replies: 2
    Last Post: 13th June 2006, 13:30
  5. QProcess in a QThread
    By chombium in forum Qt Programming
    Replies: 2
    Last Post: 11th January 2006, 15:52

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.