Proposal: Add getFullProgName
marlowsd at gmail.com
Wed Jun 13 11:05:05 CEST 2012
On 13/06/2012 05:49, Johan Tibell wrote:
> On Tue, Jun 12, 2012 at 8:08 PM, Bardur Arantsson<spam at scientician.net> wrote:
>> Not saying it's not an improvement over getProgName (definitely is), but
>> if the intent is to provide the most accurate name of the executable
>> which is running, then...
>> You should probably read the /proc/self/exe symlink on Linux. (Of course
>> /proc may not be mounted so you'll need a fallback in any case...)
>> I believe FreeBSD and Solaris have similar methods using /proc.
>> On Win32 it seems that using GetModuleFileName with a NULL first
>> parameter is the way to go:
> Good ideas. If we do that, do we also want a way to access the raw argv?
I suggest we should have a
getExecutablePath :: IO FilePath
in System.Environment. We have an implementation for Windows in GHC
that we use to find GHC's files relative to ghc.exe. This SO question
has some good references for ways to do it on different platforms:
We should also have something in System.Posix to return the original
argv, unfortunately we forgot about this when adding
System.Posix.ByteString.getArgs which returns argv[1..].
System.Posix.ByteString.getProgName :: IO ByteString
More information about the Libraries