Distribution.Client.Win32SelfUpgrade

cabal-install-3.12.1.0: The command-line interface for Cabal and Hackage.

Copyright | (c) Duncan Coutts 2008
License | BSD-like
Maintainer | cabal-devel@haskell.org
Stability | provisional
Portability | portable
Safe Haskell | None
Language | Haskell2010

Distribution.Client.Win32SelfUpgrade

Contents

- Explanation

Description

Support for self-upgrading executables on Windows platforms.

Synopsis

- possibleSelfUpgrade :: Verbosity -> [FilePath] -> IO a -> IO a
- deleteOldExeFile :: Verbosity -> Int -> FilePath -> IO ()

# Explanation

Windows inherited a design choice from DOS that while initially innocuous has rather unfortunate consequences. It maintains the invariant that every open file has a corresponding name on disk. One positive consequence of this is that an executable can always find its own executable file. The downside is that a program cannot be deleted or upgraded while it is running without hideous workarounds. This module implements one such hideous workaround.

The basic idea is:

- Move our own exe file to a new name
- Copy a new exe file to the previous name
- Run the new exe file, passing our own PID and new path
- Wait for the new process to start
- Close the new exe file
- Exit old process

Then in the new process:

- Inform the old process that we've started
- Wait for the old process to die
- Delete the old exe file
- Exit new process

possibleSelfUpgrade :: Verbosity -> [FilePath] -> IO a -> IO a #

deleteOldExeFile :: Verbosity -> Int -> FilePath -> IO () #