Volker Kuhlmann wrote:

I've always tried to avoid loading app resources into the global data
base as it's all crud other apps aren't interested in. Putting the
resources into a separate file should work (also it doesn't with some
apps). The name of the file is predefined by the app (casing is
significant and usually something funny!), and the location should be
~/lib/X11/app-defaults, which also requires a variable setting of
setenv XUSERFILESEARCHPATH ~/lib/X11/app-defaults/%N
unless the system already provides it.

If you want to know exactly which files a command opens (or tries to open) as it is executing, prepend "strace -eopen" before the command.
This is especially useful when you want to know what configuration files a command is looking for, and in what order.


For example, for ls
> strace -eopen ls

You should get about a hundred lines of opens (this is mostly library stuff, and is similar for most applications). In this exercpt:

open("/usr/local/lib/libattr.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/local/lib/libattr.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("tls/i686/libattr.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("tls/libattr.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("i686/libattr.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("libattr.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/libattr.so.1", O_RDONLY) = 3


You can see it looking in predefined places for libattr.so.1 which it finally finds in /lib

The "3" is called the file descriptor. Each open file for each process (i.e. running command) gets a unique file descriptor from the OS kernel. This can give you some hints about how long each file is opened for. I.e. if the next successful open call to the kernel also returns 3, then you know that the previous open must have been closed in order for the OS to be able to reuse the file descriptor.

Also, if you are getting overwhelmed with opens, then:
strace -eopen -ofoo
will send all the strace lines to the file foo.

strace traces all system calls, not just open. "man strace" for more information. There is also an ltrace command for tracing library calls.
Some distros might only include these trace programs for "developer"-type installations.


Cheers,
Carl.

Reply via email to