Uploaded image for project: 'Qt Solutions'
  1. Qt Solutions
  2. QTSOLBUG-184

Specified Windows service arguments are not forwarded to the created QCoreApplication

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P4: Low
    • No Version
    • No Version
    • Service
    • None
    • Windows
    • Fixed in Qt, change ff18b8e80609da91bf9e9134967dcf0d23eca9e (qtbase/dev, 5.2.2015, Qt 5.5)

    Description

      At least following problems were found when specifying service arguments to a Windows service:
      1) When you start the service from Control Panel and the Windows registry ImagePath entry contains service arguments they are not forwarded to the created QCoreApplication. The arguments are forwarded to the service's main() function, but they are overwritten in QtServiceBasePrivate::start() (qt-solutions-qt-solutions\qtservice\src\qtservice_win.cpp, line 811) with the arguments received in WinAPI ServiceMain() callback function just before the QCoreApplication is created.
      2) When the service is started from command line with myService.exe -exec /myArg=123, then you cannot use QCoreApplication::arguments(), because the -exec argument is removed in QtServiceBase::exec() function before creating the QCoreApplication. Now, QCoreApplication assumes that the arguments forwarded to its constructor equal with the command line arguments, but they don't and this gives invalid results (and an assert Q_ASSERT(allArguments.size() == origArgc) in debug).

      I was reported that both of the above scenarios have previously worked (with Qt 4).

      Steps to reproduce:

      • Build & deploy \qt-solutions\qtservice\examples\server [with diagnostic patch]
      • Open Administrator prompt
      • Install service \qt-solutions\qtservice\examples\server\httpservice[4/5] -i
      • Open control panel/services
      • On Qt HTTP test service, right click properties
      • Enter start parameters like p1 p2
      • Give commands 1,2, to service: \qt-solutions\qtservice\examples\server\httpservice[4/5] -c [1/2]
      • Press "Start" button in group box where parameters are - the setting is not persistent
      • Examine log files c:\service-debuglog[qt_version].txt

      Attachments

        1. qtsolbug184_diag.diff
          8 kB
          Friedemann Kleint
        2. service-debuglog487.txt
          2 kB
          Friedemann Kleint
        3. service-debuglog541.txt
          2 kB
          Friedemann Kleint

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              Unassigned Unassigned
              qtcomsupport Qt Support
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes