Re: [Vala] Fwd: Getting path to my program's directory
- From: Julian Andres Klode <jak jak-linux org>
- To: Michael Torrie <torriem gmail com>
- Cc: vala-list gnome org
- Subject: Re: [Vala] Fwd: Getting path to my program's directory
- Date: Sun, 06 Dec 2009 00:06:08 +0100
Am Samstag, den 05.12.2009, 13:27 -0700 schrieb Michael Torrie:
Mark Dewey wrote:
No. It doesn't work. If it did work, then sure, I'd be serious. At the
very least it would give you to know there was a way to do it.
From what I've read there is no portable way to determine the path to a
running executable. On various OS's that support /proc, you can often
glean the path from there. For example on linux, /proc/<pid#>/exe is
supposed to be a symlink to the original executable. You can use
readlink to determine the path. On BSD, there's a different entry that
contains the actual posix path.
On Linux, you can also use /proc/self/exe instead of a path with a pid
in it; on FreeBSD, it's /proc/curproc/file; and on Solaris it seems to
be "/proc/%ld/path/a.out", whereas "%ld" is the process id. All those
files are symlinks to your program.
Please note that proc is optional on FreeBSD, and that Debian
GNU/kFreeBSD has linprocfs mounted on /proc and thus behaves like the
Linux one.
Regards,
Julian
--
Julian Andres Klode - Debian Developer, Ubuntu Member
See http://wiki.debian.org/JulianAndresKlode and http://jak-linux.org/.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]