[Qt-interest] Is there anyways to check if a Process is Alive ?
jjDaNiMoTh
jjdanimoth at gmail.com
Fri Mar 26 11:33:06 CET 2010
2010/3/26 Sean Harmer <sean.harmer at maps-technology.com>:
> Hi,
>
> On Friday 26 March 2010 09:02:18 Aaron Lewis wrote:
>> More Specific for my problem:
>>
>> I want to search for Process by name on UNIX , kind like a daemon
>> process (e.g sendmail)
>
> The quick and easy solution is to use QProcess to call a system tool such as
> ps and parse the output yourself to extract the information that you need.
Maybe it's OT, but could be useful:
If possible, try to use API of that software (if it has) instead to
parse output, because if the output change (and it does very often)
you need to adjust your software.
InTopic, if you're on a UNIX system, there is no utility specifically
designed to map between program names and process IDs.
But you could do some things, like try to find the ProcessID:
ps ux | awk '/name/ && !/awk/ {print $2}'
If you find it, the process is running.
But now you have other problems: what happen if ps returns more than
one PID? And what happen if the process is still reported, by in some
critical state (like zombie, or stopped?)
--
Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
More information about the Qt-interest-old
mailing list