[Haskell-cafe] How to get a file path to the program invoked?
Peter Wortmann
scpmw at leeds.ac.uk
Thu Dec 15 15:48:01 CET 2011
Hi
I was running into a similar problem while working on GHC not long ago -
short version is that it's not even possible to find out the executable
path portably from C [1]. Using argv[0] just gave me the path of the GHC
wrapper script, for example - as it uses exec without "-a".
The whole thing is easiest if you're on Linux:
getExePath = readSymbolicLink "/proc/self/exe"
On all other operation system, one needs to start mucking around with
custom kernel calls.
Or, more realistically, try to find a way around requiring it...
Greetings,
Peter Wortmann
[1] http://stackoverflow.com/questions/1023306
More information about the Haskell-Cafe
mailing list