Re: Windows and DLLs



On Sun, Oct 04, 1998 at 07:21:22PM -0400, John Kodis wrote:
> On Sun, Oct 04, 1998 at 11:42:05AM -0700, David Jeske wrote:
> > 
> > On Sun, Oct 04, 1998 at 12:10:57PM +0200, Nils Philippsen wrote:
> > > > We would be 'best off' if we could ask the system for the full path to
> > > > the executable which was 'exec()ed' into our process.
> > 
> > I think this should be a Gnome API. We're not going to be changing
> > POSIX. That way we can implement as best we can for each system, and
> > if anyone puts it into their kernels, we can implement it with that.
> 
> After some poking around, I noticed that Linux (at least the 2.1.120
> release) offers such a mechanism already if the /proc filesystem is
> built into the kernel.
> 
> $ ls -l /proc/self/exe
> lrwx------   1 kodis  kodis   0 Oct  4 19:13 /proc/self/exe-> /bin/ls*

I looked into this a bit more carefully, and at least on my system,
this is not a 'standard' symbolic link, in that it gives back the
inode number, not the string 'path'. This makes it difficult to get
the full path of the executable back. For example, on my system:

Linux mozart 2.0.31 #1 Sun Nov 9 21:45:23 EST 1997 i586 unknown

[jeske@mozart self]$ /bin/ls -l /proc/self/exe
lrwx------   1 jeske jeske  64 Oct  6 23:45 /proc/self/exe -> [0801]:18385

According to the man page, this is exactly what it is supposed to give
back:

              exe    a pointer to the binary which was executed,
                     and appears as a symbolic link.  readlink(2)
                     on the exe special file returns a string in
                     the format:

                           22 July 1996                         1

PROC(5)             Linux Programmer's Manual             PROC(5)

                     [device]:inode

                     For example, [0301]:1502 would be inode 1502
                     on device major 03 (IDE, MFM, etc. drives)
                     minor 01 (first partition on the first
                     drive).

                     Also, the symbolic link can be dereferenced
                     normally - attempting to open "exe" will
                     open the executable.  You can even type
                     /proc/[number]/exe to run another copy of
                     the same process as [number].

                     find(1) with the -inum option can be used to
                     locate the file.


-- 
David Jeske (N9LCA) + http://www.chat.net/~jeske/ + jeske@chat.net



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