[GHC] #10957: getExecutablePath adds " (deleted)" suffix if executable was deleted under linux
GHC
ghc-devs at haskell.org
Sun Oct 11 10:09:55 UTC 2015
#10957: getExecutablePath adds " (deleted)" suffix if executable was deleted under
linux
-------------------------------------+-------------------------------------
Reporter: aslpavel | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Core | Version: 7.10.2
Libraries |
Keywords: | Operating System: Linux
Architecture: | Type of failure: Incorrect result
Unknown/Multiple | at runtime
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
If we remove current executable or update it with a new one,
getExecutablePath returns path with added " (deleted)" suffix. I think it
is incorrect behavior
, for example if you updated binary and want to exec a new one, the
obvious way to go is to call getExecutablePath and use it. Moreover it is
inconsistent between platforms. Problem stems from the fact the
getExecutablePath is implemented as readlink on /proc/self/exe and it
contains gibberish once file has been deleted.
Example:
{{{#!hs
module Main (main) where
import System.Environment (getExecutablePath)
import System.Directory (removeFile)
main :: IO ()
main = do
before <- getExecutablePath
putStrLn $ "Before: " ++ before
removeFile before
after <- getExecutablePath
putStrLn $ "After: " ++ after
}}}
Output:
{{{
$ ./getExecutablePath
Before: /mnt/data/Maggot/getExecutablePath
After: /mnt/data/Maggot/getExecutablePath (deleted)
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10957>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list