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. How to force kill a QProcess instance when it's state() is Starting.

How to force kill a QProcess instance when it's state() is Starting.

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 323 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.
  • G Offline
    G Offline
    Gerald.L.
    wrote on last edited by Gerald.L.
    #1

    When I try to force kill a QProcess instance, how should I deal with the case process->state() == QProcess::Starting ?

    I checked the Qt source code, the Starting state appear for a very short time, in void QProcessPrivate::startProcess(), set at begining, changed to Running / NotRunning after forkfd() ( a wrapper of fork() ?) success /fail. The QProcess::kill() member function I use to force kill process uses the pid returned from forkfd() . So, when process->state() == QProcess::Starting and kill() is called, whether the child-process pid is there is not certain.

    Should I wait for the process started? What's the elegant way to force kill a QProcess instance?

    jsulmJ 1 Reply Last reply
    0
    • G Gerald.L.

      When I try to force kill a QProcess instance, how should I deal with the case process->state() == QProcess::Starting ?

      I checked the Qt source code, the Starting state appear for a very short time, in void QProcessPrivate::startProcess(), set at begining, changed to Running / NotRunning after forkfd() ( a wrapper of fork() ?) success /fail. The QProcess::kill() member function I use to force kill process uses the pid returned from forkfd() . So, when process->state() == QProcess::Starting and kill() is called, whether the child-process pid is there is not certain.

      Should I wait for the process started? What's the elegant way to force kill a QProcess instance?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Gerald-L said in How to force kill a QProcess instance when it's state() is Starting.:

      Should I wait for the process started?

      I would do it like this, yes

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      3

      • Login

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