Results 1 to 5 of 5

Thread: multiple process ID while QProcess start() function

  1. #1
    Join Date
    Nov 2014
    Posts
    3
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Android

    Default multiple process ID while QProcess start() function

    Hi

    Im my program, activating the the GPRS using Qprocess start function, while executing this program will activate the GPRS. But the application is creating two more process PID with same application name & that two process will not be terminating. kindly help me how to solve this problem.
    Qt Code:
    1. void GPRSCall::activateGPRS() {
    2. QProcess *activateProcess;
    3. activateProcess = new QProcess();
    4. connect(activateProcess,SIGNAL(readyReadStandardOutput()),this,SLOT(readGPRS()));
    5. activateProcess->start("pppd call gprs-airtel",QIODevice::ReadOnly);
    6. }
    7.  
    8. void GPRSCall::readGPRS()
    9. {
    10. str = activateProcess->readAllStandardOutput();
    11. qDebug() << str;
    12. if(str.contains("local IP address")) {
    13. QString ipAddress=getip("ppp0");
    14. emit gprsResponse(tr("GPRS Activated Successfully<br>IP : ")+ipAddress);
    15. activateProcess->disconnect(activateProcess,SIGNAL(readyReadStandardOutput()),this,SLOT(readGPRS()));
    16. } else if(str.contains("script failed") || str.contains("Serial link disconnected")) {
    17. emit gprsResponse(tr("GPRS Activation Failed"));
    18. activateProcess->disconnect(activateProcess,SIGNAL(readyReadStandardOutput()),this,SLOT(readGPRS()));
    19. } else if(str.contains("ttyUSB0 is locked")) {
    20. emit gprsResponse(tr("GPRS Activation Failed"));
    21. }
    22. else if(str.contains("Modem hangup")) {
    23. emit gprsResponse(tr("Modem Hangup"));
    24. activateProcess->disconnect(activateProcess,SIGNAL(readyReadStandardOutput()),this,SLOT(readGPRS()));
    25. }
    26. }
    27.  
    28. /*Obtains the IP Address from the conncted network interrface*/
    29. QString GPRSCall::getip(QString dev)
    30. {
    31. QNetworkInterface iface = QNetworkInterface::interfaceFromName(dev);
    32. QList<QNetworkAddressEntry> ipList = iface.addressEntries();
    33. for (int i = 0; i < ipList.size(); ++i)
    34. return ipList.at(i).ip().toString();
    35. return "No Link";
    36. }
    37.  
    38.  
    39. /********************GPRS Deactivation********************/
    40. /*GPRS Disconnect Script is called from a process in ReadOnly Mode*/
    41. void GPRSCall::deactivateGPRS()
    42. {
    43. connect(deactivateProcess,SIGNAL(readyReadStandardOutput()),this,SLOT(closeGPRS()));
    44. deactivateProcess->start("sh /opt/Resources/gprs_disconnect.sh",QIODevice::ReadOnly);
    45. delay(1);///add Stopping PPP interface to readyreadstandarouuput method...
    46. }
    47.  
    48. /***************Read Deactivation Script Output***************/
    49. /*Invoked form Disconnect Script to read its output and display
    50.   the status to the user*/
    51. void GPRSCall::closeGPRS()
    52. {
    53. str = deactivateProcess->readAllStandardOutput();
    54. if(str.contains("Stopping PPP interface ")) {
    55. emit gprsResponse(tr("GPRS Deactivation Success"));
    56. deactivateProcess->disconnect(deactivateProcess,SIGNAL(readyReadStandardOutput()),this,SLOT(closeGPRS()));
    57. }
    58. }
    To copy to clipboard, switch view to plain text mode 
    Note : USing QT 4.8.1 version & Linux 2.6.36.4 armv5tejl GNU/Linux
    Last edited by anda_skoa; 26th November 2014 at 09:21. Reason: missing [code] tags

  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: multiple process ID while QProcess start() function

    That should actually crash.

    activateGPRS() is storing the QProcess pointer in a local variable, readGPRS() is accessing a member variable.

    Cheers,
    _

  3. #3
    Join Date
    Nov 2014
    Posts
    3
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Android

    Default Re: multiple process ID while QProcess start() function

    Hi,
    Thank for your reply, I extended scope of QProcess by declaring it in header file. Now also I am getting same problem.

    QT Code
    void GPRSCall::activateGPRS() {
    // QProcess *activateProcess; // Moved to Header file
    // activateProcess = new QProcess(); // Moved to constructor.
    connect(activateProcess,SIGNAL(readyReadStandardOu tput()),this,SLOT(readGPRS()));
    activateProcess->start("pppd call gprs-airtel",QIODevice::ReadOnly);
    }

  4. #4
    Join Date
    Nov 2014
    Posts
    3
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Android

    Default Re: multiple process ID while QProcess start() function

    Hi,
    Thank for your reply, I extended scope of QProcess by declaring it in header file. Now also I am getting same problem.

    QT Code
    void GPRSCall::activateGPRS() {
    // QProcess *activateProcess; // Moved to Header file
    // activateProcess = new QProcess(); // Moved to constructor.
    connect(activateProcess,SIGNAL(readyReadStandardOu tput()),this,SLOT(readGPRS()));
    activateProcess->start("pppd call gprs-airtel",QIODevice::ReadOnly);
    }

  5. #5
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: multiple process ID while QProcess start() function

    Hi,

    Use a debugger and check how many times "activateGPRS()" is called.
    Òscar Llarch i Galán

Similar Threads

  1. Replies: 1
    Last Post: 3rd June 2013, 13:11
  2. Replies: 4
    Last Post: 4th January 2012, 22:43
  3. "Process failed to start: " and qprocess generic errors
    By scott_hollen in forum Qt Programming
    Replies: 8
    Last Post: 22nd November 2011, 15:03
  4. Replies: 0
    Last Post: 26th August 2010, 10:44
  5. The Gdb process failed to start.
    By been_1990 in forum Qt Tools
    Replies: 3
    Last Post: 29th April 2009, 17:29

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.