0

I have Qt Application that executes a process when you click on a button.

I used this method QProcess::startDetached(...,qint64 * pid) : http://doc.qt.io/qt-5/qprocess.html#startDetached

The returned value is a pid and I would like to do a kill(pid, SIGINT) in windows.

It works well on Mac but I don't know how to do that in windows.

John Smith
  • 771
  • 4
  • 11
  • 25
  • formal you need `TerminateProcess(OpenProcess(PROCESS_TERMINATE, FALSE, pid), 0)` – RbMm Sep 11 '17 at 19:50
  • are you sure that the process can receive a SIGINT and terminate properly? – John Smith Sep 11 '17 at 19:53
  • i absolute sure that it not receive `SIGINT` because no any `SIGINT` in windows. the process at all nothing receive. and it not terminate properly. it simply terminated – RbMm Sep 11 '17 at 20:05
  • 2
    It is a strange idea - start a process as detached - and then want to get access to it). If you want to control a process, why just don't create and start it by [QProcess::start()](http://doc.qt.io/qt-5/qprocess.html#start) and kill by [QProcess::kill()](http://doc.qt.io/qt-5/qprocess.html#kill) ? In addition, you can also then not think about Мас and Windows (from doc: _On Windows, kill() uses TerminateProcess, and on Unix and macOS, the SIGKILL signal is sent to the process._) – Vladimir Bershov Sep 11 '17 at 20:17
  • Short answer: no. Use a proper IPC mechanism, e.g., a named event object. Long answer: see the proposed duplicate. – Harry Johnston Sep 12 '17 at 00:07

0 Answers0