I may be doing a horrible misinterpretation of the subject, but here goes
nothing.

> > > > This just uses the existing logic in mch_can_exe to populate a buffer 
> > > > with the
> > > > absolute path to the binary.  The Windows code was already walking
> > > > $PATH, so it seems pointless not to actually use the information.
> > > 
> > > Quite a few years ago I was debugging a Vim that started up slowly.  It
> > > turned out that walking through $PATH was the main cause for that.  So I
> > > don't want to walk through $PATH when not really needed.
> > 
> > Then it would be better to use platform-specific functionality to get
> > the absolute path of the running binary instead of trying to re-use
> > functionality that's intended for a different purpose.
> 
> What platform-specific functionality is there?  Perhaps Linux has a way
> to get the actual path, instead of using argv[0]?

Standard unix (as in SUSv3) does not have any specified way to determine the
running binary.  It really is a thing of comparing argv[0] whilst walking
through PATH.  And it has more sheanigans that you may at first think: there's
the tilde (~) and all relative PATH.  Just look at the GNU which source to see
that madness:
http://cvs.savannah.gnu.org/viewvc/which/which/which.c?revision=1.41&view=markup

And then you can run `realpath(3)` to get the absolute path.

On the other hand, on *Linux* you can use `readlink(3)` on `/proc/self/exe` and
you get the absolute path of the running binary.  FreeBSD (and a handful of
other BSDs support the same interface too).

i.e.

    #include <limits.h>
    #include <unistd.h>

    char buf[PATH_MAX+1];
    ssize_t len;

    len = readlink("/proc/self/exe", buf, PATH_MAX);
    buf[len] = '\0'

Should *always* work on Linux.

-- 
Mike Grochmal
GPG key ID 0xC840C4F6

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui