Re: Getting a list of open files, the smart way?



On Thu, 2008-05-15 at 11:50 +0100, Gustavo J. A. M. Carneiro wrote:
> On Wed, 2008-05-14 at 19:10 -0500, Diego Escalante Urrelo wrote:
> > Hi,
> > 
> > I have made a quite simple patch for bug 528559[0], it makes the quite
> > useless "drive is being used" dialog into a list of applications using
> > such drive[1].
> > 
> > I'm using a little hack with lsof, but it's not really reliable, like
> > when process names are too long. I checked libgtop quickly but the
> > lack of documentation didn't help.

Some time ago I worked on a similar feature, but I never finished it.
Here's the relevant page in the libgtop documentation:

http://library.gnome.org/devel/libgtop/stable/libgtop-procopenfiles.html

I also discovered that, additionally, processes whose current working
directory is on the filesystem in question can also prevent unmounting.

> > So, I'm writing to get some clues about this, any advice? My main
> > problem is to do something like "tell me which files in device $d are
> > in use, and tell me the executable for the process using such file"

You will have to iterate over all processes and check their open files
using the above-mentioned libgtop functions.

> If you have time, you could go two steps further than "the executable
> for the process using such file":
> 
>   1- Try to find a .desktop file associated with the exe and display the
> application name and icon instead;

I would suggest first trying to find the window corresponding to the pid
using libwnck:

http://library.gnome.org/devel/libwnck/stable/

If a window exists for the process you could use the window's icon and
title, which are more recognizable to the user since they correspond
to the panel's window list.

Thanks for taking the time to work on this much-needed feature,

Christian Glodt

>   2- Offer options (button?) to terminate each of the applications
> (SIGTERM first then SIGKILL if SIGTERM does not work after a while)
> 
> > 
> > thanks everyone,
> > 
> > Diego
> > 
> > 0 - http://bugzilla.gnome.org/show_bug.cgi?id=528559
> > 1 - http://bugzilla.gnome.org/attachment.cgi?id=109417
> > _______________________________________________
> > desktop-devel-list mailing list
> > desktop-devel-list gnome org
> > http://mail.gnome.org/mailman/listinfo/desktop-devel-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]