Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Two qprocess using the same variable

Two qprocess using the same variable

Scheduled Pinned Locked Moved General and Desktop
9 Posts 2 Posters 1.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Magnum
    wrote on last edited by
    #1

    Hello,

    Can anyone tell me why this code stops the first bash shell??

    @int main(int argc, char* argv[]) {
    QApplication app(argc, argv);
    app.setApplicationName("QonsoleKeyEvents");
    app.setOrganizationName("objectlearning.net");
    QProcess* aProcess = new QProcess();
    aProcess->start("bash", QStringList("-i"), QIODevice::ReadWrite);
    aProcess = new QProcess();
    aProcess->start("bash", QStringList("-i"), QIODevice::ReadWrite);
    return app.exec();
    }
    @

    What would be the proper way to save references to multiple qprocess??

    Thanks.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What do you mean by "stops the first bash shell" ?

      Use one variable per QProcess

      You also have a double memory leak. You don't delete your two QProcess and you lose the address of the first.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Magnum
        wrote on last edited by
        #3

        I mean that when you execute this code you get the following:

        bq. [1]+ Stopped

        I did it on purpose, I only wanted to know if the first process was stopped.
        I don't get why this happens.
        Any idea?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          How do you get this message ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Magnum
            wrote on last edited by
            #5

            The problem only happens if the binary is executed from the terminal. I'm not sure why this happens.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Are you sure that the Stopped is about the bash session started with QProcess ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • M Offline
                M Offline
                Magnum
                wrote on last edited by
                #7

                I think so. Anyway, I executed it from dolphin and works flawlessly.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  So if you consider this solved, could you update the thread title ?

                  Don't forget to clean your code of the memory leaks

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    Magnum
                    wrote on last edited by
                    #9

                    I don't think I must mark it as solved because I don't know the real cause.

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved