[Haskell-cafe] How to get a file path to the program invoked?

scooter.phd at gmail.com scooter.phd at gmail.com
Mon Dec 5 03:34:06 CET 2011


That's true even for regular fork/exec. 

-----Original message-----
From: Richard O'Keefe <ok at cs.otago.ac.nz>
To: wren ng thornton <wren at freegeek.org>
Cc: haskell-cafe <haskell-cafe at haskell.org>
Sent: Sun, Dec 4, 2011 15:54:15 PST
Subject: Re: [Haskell-cafe] How to get a file path to the program invoked?


On 4/12/2011, at 7:32 PM, wren ng thornton wrote:
> Part of the problem is that, as Alexey says, the first element of argv is  
just whatever is passed to exec, which is not guaranteed to be a complete  
path, a canonical path, or any other specific thing we'd desire. It's not at  
all straightforward to determine the actual location of the executable,  
especially not in a platform-independent manner. argv[0] can't be trusted,  
scanning through $PATH isn't guaranteed to find it (and even if you find  
something of the right name, it's not guaranteed to be the correct  
executable), etc etc.

In particular, with posix_spawnp(), the $PATH that is used to find the  
executable
and the $PATH in the environment that the executable starts with can be two  
different things.


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe at haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20111204/03bfcbfd/attachment.htm>


More information about the Haskell-Cafe mailing list