On Wed, January 12, 2005 8:00 am, Carl Cerecke said:
> 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.
It might be an idea at this time to point out that by default every
process ( or it it just those written in C - I forget - but most of the
kernel is anyway... ) opens 3 descriptors on startup...
0 = stdin
1 = stdout
2 = stderr
which are designed for input, output and error messages respectively. This
is why the file open above used file descriptor 3, which is the first one
available, and not ( as can be expected at times like this ) just a
contrary choice!
Steve
>
> 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.
>
--
Artificial Intelligence is no match for natural stupidity.