Saturday, May 4, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 563  / 2 Years ago, mon, november 7, 2022, 9:12:26

I wrote a daemon in C++ which is automatically started on login using a bash script placed in /etc/profile.d/ while running the install section of my makefile. The problem is that when I log out and log back in, there are now two instances of the daemon running.



What I would have liked is for the first one to stop when I logged out, not keep going. It's only meant to run while somebody is logged in, anyhow. How do I make sure my daemon is not still running after I logout?


More From » programming

 Answers
6

If you're using D-Bus in your application, you could listen for the SessionOver signal on the org.gnome.SessionManager interface. With C++ Qt5, your code would look something like this:



QDBusConnection dbus = QDBusConnection::sessionBus();
dbus.connect("org.gnome.SessionManager", "",
"org.gnome.SessionManager", "SessionOver",
this, SLOT(handle_sessionOver());


References:




[#25773] Tuesday, November 8, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
fulpu

Total Points: 116
Total Questions: 118
Total Answers: 104

Location: Solomon Islands
Member since Fri, Oct 8, 2021
3 Years ago
fulpu questions
Fri, Apr 1, 22, 08:36, 2 Years ago
Wed, Mar 16, 22, 15:25, 2 Years ago
Wed, Aug 24, 22, 22:59, 2 Years ago
Tue, Dec 20, 22, 22:33, 1 Year ago
;