Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Qt DBus unable to detect an exit status of zero

Qt DBus unable to detect an exit status of zero

Scheduled Pinned Locked Moved Unsolved C++ Gurus
12 Posts 3 Posters 3.9k Views 3 Watching
  • 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi and welcome to devnet,

    I'm not sure I'm following you. Do you mean that you have this problem if the dbus-daemon exits normally ?

    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
    • J Offline
      J Offline
      josephdp
      wrote on last edited by josephdp
      #3

      Hi @SGaist,

      Thank you for your response and for the warm welcome.

      There's no problem with dbus-daemon since it will never exit and is always running.

      The problem is with the services launched and when it exits normally (exit code: 0).

      P.S. all services are running on the session bus

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

        To be sure I understand correctly: you are doing a call to your service that results in it exiting normally but then you get a timeout error, right ?

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

        J 1 Reply Last reply
        0
        • SGaistS SGaist

          To be sure I understand correctly: you are doing a call to your service that results in it exiting normally but then you get a timeout error, right ?

          J Offline
          J Offline
          josephdp
          wrote on last edited by
          #5

          Hi @SGaist,

          Yes you got it right.

          Do you happen to know if this is a bug in QT 5.5.1 DBus?

          kshegunovK 1 Reply Last reply
          0
          • J josephdp

            Hi @SGaist,

            Yes you got it right.

            Do you happen to know if this is a bug in QT 5.5.1 DBus?

            kshegunovK Offline
            kshegunovK Offline
            kshegunov
            Moderators
            wrote on last edited by
            #6

            @josephdp
            How does your service exit? Can you provide a very minimal snippet illustrating the function you're calling?

            Read and abide by the Qt Code of Conduct

            1 Reply Last reply
            0
            • J Offline
              J Offline
              josephdp
              wrote on last edited by
              #7

              Hi @kshegunov, @SGaist,

              My service exits with a exit code of 0 if successful and non-zero for error.

              The problem is QT DBus can't understand perhaps an exit code of 0 which means success?

              Please see minimal snippet:

              QDBusConnection session = QDBusConnection::sessionBus ();
              QDBusMessage msg = QDBusMessage::createMethodCall ("com.myservice.foo",
                                                                  "/com/myservice/foo",
                                                                  "com.myservice.foo",
                                                                  "mymethod");
              
              QDBusPendingCall call = session.asyncCall (msg,  120000);
              
              QDBusPendingCallWatcher * watcher = new QDBusPendingCallWatcher (call);
              
              QObject::connect(watcher,
                               SIGNAL (finished(QDBusPendingCallWatcher*)),
                               this,
                               SLOT (onMethodFinished(QDBusPendingCallWatcher*)));
              

              and for the onMethodFinished ():

              QDBusPendingCall reply = * call;
              
              if (reply.isError()) {
                  QString text = reply.reply().errorMessage();
                  qDebug () << __FUNCTION__ << "Error: " << text;
              } else {
                  qDebug () << __FUNCTION__ << "OK";
              }
              call->deleteLater();
              
              kshegunovK 1 Reply Last reply
              0
              • J josephdp

                Hi @kshegunov, @SGaist,

                My service exits with a exit code of 0 if successful and non-zero for error.

                The problem is QT DBus can't understand perhaps an exit code of 0 which means success?

                Please see minimal snippet:

                QDBusConnection session = QDBusConnection::sessionBus ();
                QDBusMessage msg = QDBusMessage::createMethodCall ("com.myservice.foo",
                                                                    "/com/myservice/foo",
                                                                    "com.myservice.foo",
                                                                    "mymethod");
                
                QDBusPendingCall call = session.asyncCall (msg,  120000);
                
                QDBusPendingCallWatcher * watcher = new QDBusPendingCallWatcher (call);
                
                QObject::connect(watcher,
                                 SIGNAL (finished(QDBusPendingCallWatcher*)),
                                 this,
                                 SLOT (onMethodFinished(QDBusPendingCallWatcher*)));
                

                and for the onMethodFinished ():

                QDBusPendingCall reply = * call;
                
                if (reply.isError()) {
                    QString text = reply.reply().errorMessage();
                    qDebug () << __FUNCTION__ << "Error: " << text;
                } else {
                    qDebug () << __FUNCTION__ << "OK";
                }
                call->deleteLater();
                
                kshegunovK Offline
                kshegunovK Offline
                kshegunov
                Moderators
                wrote on last edited by
                #8

                @josephdp
                I meant the service's method you're calling - mymethod from /com/myservice/foo.

                Read and abide by the Qt Code of Conduct

                1 Reply Last reply
                0
                • J Offline
                  J Offline
                  josephdp
                  wrote on last edited by
                  #9

                  Hi @kshegunov

                  Basically it will just return 0 on success and 1 on failure.

                  mymethod ()
                  {
                      bool rc = do_something ();
                  
                      if (rc) {
                          // success
                          return 0;
                      } else {
                          // failure
                          return 1;
                      }
                  }
                  
                  kshegunovK 1 Reply Last reply
                  0
                  • J josephdp

                    Hi @kshegunov

                    Basically it will just return 0 on success and 1 on failure.

                    mymethod ()
                    {
                        bool rc = do_something ();
                    
                        if (rc) {
                            // success
                            return 0;
                        } else {
                            // failure
                            return 1;
                        }
                    }
                    
                    kshegunovK Offline
                    kshegunovK Offline
                    kshegunov
                    Moderators
                    wrote on last edited by
                    #10

                    What I was concerned about is if your application gives up before it's able to close the DBus connection cleanly. Meaning you calling ::exit() somewhere or having an unexpected SIGSEGV signal raised somewhere.

                    Read and abide by the Qt Code of Conduct

                    1 Reply Last reply
                    0
                    • J Offline
                      J Offline
                      josephdp
                      wrote on last edited by
                      #11

                      Hi @kshegunov

                      Basically this is the final sequence of the app.

                      It is able to return immediately if the app returns a non-zero value (which in this case is 1).
                      However, if it will return a zero value (success in this case), the caller will wait for the timeout set (120000) and will inform a false negative result (that "Failed to activate service 'com.myservice.foo': timed out.)

                      kshegunovK 1 Reply Last reply
                      0
                      • J josephdp

                        Hi @kshegunov

                        Basically this is the final sequence of the app.

                        It is able to return immediately if the app returns a non-zero value (which in this case is 1).
                        However, if it will return a zero value (success in this case), the caller will wait for the timeout set (120000) and will inform a false negative result (that "Failed to activate service 'com.myservice.foo': timed out.)

                        kshegunovK Offline
                        kshegunovK Offline
                        kshegunov
                        Moderators
                        wrote on last edited by
                        #12

                        Is it possible you don't have an event loop running at this point? I don't see a good reason for that behavior, so I'm starting to guess now ...

                        Read and abide by the Qt Code of Conduct

                        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