Re: 'hacking' some of XFCE goodies

Łukasz Hejnak <[email protected]>
Newsgroups gmane.comp.desktop.xfce.goodies.devel
Message-ID <[email protected]>
Hi..

Ondrej Mihalyi wrote:
> Didn't try your app, but I think that it would help, if instead of system() you would use combination of fork(), exec() and waitpid().  Idea is to use fork and exec to spawn the 'top' process and then periodically use non-blocking version of waitpid (there are some flags to make it non-blocking) to check whether the 'top' process finished.
> I know that you may well not be familiar with those functions, but if you want to succeed in making your app better, I believe that this is kind of easy way how to do it.

Thanks for the help! Indeed I knew not much about these functions, but I 
googled something about what You wrote and I think I got it right :]

I had a problem with the number of "xfce4-panel <defunct>" growing to 
milions but I set a kill()er for them and now I think it works without 
any problems..
The trace can be found in /tmp dir - where are the top.pid top.old and 
top.lista files.

The forked child does a system() call to `top` to retrieve info on 
running processes and channels it to top.lista.
The top.pid contains the forked child's pid, to trace the status of it,
when it's over a kill() signal is sent to get rid of the zombie.
Then the program retrieves data from top.lista, stores the parsed 
version in top.old and forks a new process.
While the process is running again, the top.old is used for data source 
and so on...

The updated (and I hope final) version is already available at the 
standard location:
http://szift.org/xfce/xfce4-cpugraph-plugin-szifted.tar.bz2

Have a nice run :)

--
Best wishes
Łukasz Hejnak
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.