tags:

views:

83

answers:

2

I was wondering how I could do something like this (source) using Qt. I looked through the documentation but couldn't find any method to check if an external process is running.

if [ "$(pidof ksmserver)" ]; then
   echo "KDE running."
   # KDE-specific stuff here
elif [ "$(pidof gnome-session)" ]; then
   echo "GNOME running."
   # GNOME-specific stuff here
elif [ "$(pidof xfce-mcs-manage)" ]; then
   echo "Xfce running."
   # Xfce-specific stuff here
fi
+1  A: 

I believe the correct way to do what pidof does is to look at entries in /proc. There's another thread on this here: http://stackoverflow.com/questions/374997/find-pid-of-a-process-by-name-without-using-popen-or-system

siride
+1  A: 

Use QProcess to run pidof foo,then check its stdout?If this is not what you want,search /proc/.

schemacs
Just what I needed, thank you.
Jake Petroules