Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get all running processes in Qt

I have two questions:

  1. Is there any API in Qt for getting all the processes that are running right now?
  2. Given the name of a process, can I check if there is such a process currently running?
like image 243
user758795 Avatar asked Sep 15 '25 00:09

user758795


1 Answers

Process APIs are notoriously platform-dependent. Qt provides just the bare minimum for spawning new processes with QProcess. Interacting with any processes on the system (that you didn't start) is out of its depth.

It's also beyond the reach of things like Boost.Process. Well, at least for now. Note their comment:

Boost.Process' long-term goal is to provide a portable abstraction layer over the operating system that allows the programmer to manage any running process, not only those spawned by it. Due to the complexity in offering such an interface, the library currently focuses on child process management alone.

I'm unaware of any good C++ library for cross-platform arbitrary process listing and management. You kind of have to just pick the platforms you want to support and call their APIs. (Or call out to an external utility of some kind that will give you back the info you need.)

like image 106
HostileFork says dont trust SE Avatar answered Sep 17 '25 18:09

HostileFork says dont trust SE