[Qt-interest] Is there anyways to check if a Process is Alive ?

Sean Harmer sean.harmer at maps-technology.com
Fri Mar 26 11:47:45 CET 2010


On Friday 26 March 2010 10:29:55 Srdjan Todorovic wrote:
> On 26/03/2010, Sean Harmer <sean.harmer at maps-technology.com> wrote:
> > Longer option is to look at the code of ps and see what it does.
> 
> Problem is, the OP doesn't want to use /proc for compatibility reasons..
> 
> And a sample run of 'ps' on my Linux box:
> 
> stat64("/proc/9961", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
> open("/proc/9961/stat", O_RDONLY)       = 6
> read(6, "9961 (kwin) S 9946 9946 9946 0 -"..., 1023) = 194
> close(6)
> 
> Which repeats for each process... So it seems that 'ps' just reads
> files in /proc and then pretty-prints the information to screen.
> 
> Although, perhaps looking at the source of 'ps' on *BSD might help
> come up with a design where there are platform dependent classes to
> access process list and then have some method of switching these.
> Perhaps a Strategy Pattern that is selected using the Q_OS_FREEBSD,
> Q_OS_LINUX, Q_OS_NETBSD and Q_OS_OPENBSD macros from QtGlobal ?

Yes but I never specified to only look at source of ps on a single platform. 
Obviously if he wants it to work cross-platform he will need to provide 
platform-specific code for each one that he wishes to support. If the OP then 
decides to wrap this up in a nice Qt API and submit as a merge request on 
gitorious then so much the better ;-)

Sean

> 
> Srdjan
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest



More information about the Qt-interest-old mailing list