Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit ade060c

Browse files
committed
[RCD-52] cardano-launcher | win64: kill self via PID, not process name
1 parent 4f36eb7 commit ade060c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tools/src/launcher/Main.hs

+8-4
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ import Text.PrettyPrint.ANSI.Leijen (Doc)
5757
#ifndef mingw32_HOST_OS
5858
import System.Posix.Signals (sigKILL, signalProcess)
5959
import qualified System.Process.Internals as Process
60+
#else
61+
import qualified System.Win32.Process as Process
6062
#endif
6163

6264
-- Modules needed for system'
@@ -551,7 +553,9 @@ runUpdater ndbp ud = do
551553
Nothing -> runUpdaterProc path args'
552554
Just rp -> do
553555
-- Write the bat script and pass it the updater with all args
554-
writeWindowsUpdaterRunner rp
556+
#ifdef mingw32_HOST_OS
557+
writeWindowsUpdaterRunner rp =<< liftIO Process.getCurrentProcessId
558+
#endif
555559
-- The script will terminate this updater so this function shouldn't return
556560
runUpdaterProc rp ((toText path):args')
557561
case exitCode of
@@ -582,12 +586,12 @@ runUpdaterProc path args = do
582586
phvar <- newEmptyMVar
583587
system' phvar cr mempty EUpdater
584588

585-
writeWindowsUpdaterRunner :: FilePath -> M ()
586-
writeWindowsUpdaterRunner runnerPath = liftIO $ do
589+
writeWindowsUpdaterRunner :: FilePath -> Process.ProcessId -> M ()
590+
writeWindowsUpdaterRunner runnerPath selfPid = liftIO $ do
587591
exePath <- getExecutablePath
588592
launcherArgs <- getArgs
589593
writeFile (toString runnerPath) $ unlines
590-
[ "TaskKill /IM cardano-launcher.exe /F"
594+
[ "TaskKill /PID "<>show selfPid<>" /F"
591595
-- Run updater
592596
, "%*"
593597
-- Delete updater

0 commit comments

Comments
 (0)