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

Commit a43f378

Browse files
authored
Merge pull request #3926 from input-output-hk/rcd-52-indiscriminate-killing
[RCD-52] cardano-launcher | win64: kill self via PID, not process name
2 parents 9c6b953 + 947b046 commit a43f378

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

tools/cardano-sl-tools.cabal

+2
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ executable cardano-launcher
222222
, yaml
223223
if !os(windows)
224224
build-depends: unix
225+
else
226+
build-depends: Win32
225227
default-language: Haskell2010
226228
ghc-options: -threaded
227229
-Wall

tools/src/launcher/Main.hs

+9-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
{-# LANGUAGE RecordWildCards #-}
1313
{-# LANGUAGE TemplateHaskell #-}
1414
{-# LANGUAGE TypeSynonymInstances #-}
15+
{-# OPTIONS_GHC -Wno-type-defaults #-}
1516

1617
import qualified Prelude (show)
1718
import Universum
@@ -57,6 +58,8 @@ import Text.PrettyPrint.ANSI.Leijen (Doc)
5758
#ifndef mingw32_HOST_OS
5859
import System.Posix.Signals (sigKILL, signalProcess)
5960
import qualified System.Process.Internals as Process
61+
#else
62+
import qualified System.Win32.Process as Process
6063
#endif
6164

6265
-- Modules needed for system'
@@ -586,8 +589,13 @@ writeWindowsUpdaterRunner :: FilePath -> M ()
586589
writeWindowsUpdaterRunner runnerPath = liftIO $ do
587590
exePath <- getExecutablePath
588591
launcherArgs <- getArgs
592+
#ifdef mingw32_HOST_OS
593+
selfPid <- Process.getCurrentProcessId
594+
#else
595+
let selfPid = 0 -- This will never be run on non-Windows
596+
#endif
589597
writeFile (toString runnerPath) $ unlines
590-
[ "TaskKill /IM cardano-launcher.exe /F"
598+
[ "TaskKill /PID "<>show selfPid<>" /F"
591599
-- Run updater
592600
, "%*"
593601
-- Delete updater

0 commit comments

Comments
 (0)