Junaid Qadir Shekhanzai
Junaid Qadir Shekhanzai

Reputation: 1425

How to monitor a service in Linux via C++in QT?

I'm working on a small app to test waters in C++ using QT Creator on a Ubuntu box.

Here's the deal, I wanted to Start/Stop a certain service and as well monitor it's status in case it is started/stopped outside my app.

I got the first part covered which is starting/stopping the service using QProcess.

While reading about the QProcess I came accross this but unfortunately I can't make much sense of it to implement it.

I'd really appreciate some help here.

Regards,

Upvotes: 0

Views: 1298

Answers (1)

anttix
anttix

Reputation: 7779

Starting / Stopping services on a Linux box is best done via its service management interface and not via QProcess. Given that your project is new, I would not try to support Ubuntu proprietary service manager (Upstart) and instead build support for systemd that will replace it in the near future.

First you need to install systemd.

https://askubuntu.com/questions/420917/how-can-i-replace-upstart-with-systemd

Then try out this C++ library:

https://github.com/ilpianista/libsystemd-qt

Upvotes: 2

Related Questions