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. Process is not killing if started using QProcess::startDetached()
Forum Updated to NodeBB v4.3 + New Features

Process is not killing if started using QProcess::startDetached()

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 7.8k Views 1 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.
  • A Offline
    A Offline
    aashish.lg
    wrote on last edited by
    #1

    I am executing one qt process using QProcess::startDetached() from my Qt application.
    New process is starting successfully, but when I wanted to kill this process using QProcess::kill() OR Terminate() method my new process is not terminating.

    Note:- Most of the times after QProcess::startDetached() call, the pid of the newly created process is coming zero.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      I don't get it. StartDetached is a static method. It only returns a boolean, but it does not operate on any instance of a QProcess object. It does not tell you the pid at all. How do you plan to call kill or terminate on it? These methods are slots that do operate on an instance of QProcess. What instance are you using for that?

      The whole idea of using startDetached is that you do a fire-and-forget: you start the process, but you don't want any control of it anymore. It will even continue to live after your own process has terminated.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        aashish.lg
        wrote on last edited by
        #3

        Thanks for your suggestion. But actually as per the documentation of startDetached() function, the last parameter returns the pid of the newly created process.

        My newly launched process constructor is doing below mentioned things.

        1. Loading some shared library and resolving exported functions.
        2. Creating one localserver and connecting newconnection slot.

        Sometimes I will get the pid of my newly created process in the last param of startDetached() method, but most of the times it is 0.

        Please suggest how can I get the pid of newly created process.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          You are right, the last argument of the most extended overload of startDetached allows you to get back the pId, according to the documentation. Note that that still does not change my argument above that QProcess::kill or terminate won't work on them.

          Could you show some code? Judging by the documentation, if the pId returned is 0, that would mean that starting the process failed (so the return value should also be false).

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Asperamanca
            wrote on last edited by
            #5

            If you are working on Windows (Vista, 7, 8), don't expect the pId you get to be any use. It might well be just an intermediate pId that Windows throws away once it starts the real process. This is done to implement the "UAC":http://en.wikipedia.org/wiki/User_Account_Control.

            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