Skip to content

Commit ad199c4

Browse files
committed
fix: NSIS uninstaller doesn't kill child processes
Close #2516
1 parent c6f96d3 commit ad199c4

File tree

5 files changed

+52
-50
lines changed

5 files changed

+52
-50
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@
6565
"temp-file": "^3.1.1",
6666
"tunnel-agent": "^0.6.0",
6767
"update-notifier": "^2.3.0",
68-
"yargs": "^10.1.1"
68+
"yargs": "^11.0.0"
6969
},
7070
"devDependencies": {
7171
"@develar/gitbook": "3.2.11",
7272
"@types/debug": "^0.0.30",
7373
"@types/ejs": "^2.5.0",
7474
"@types/electron-is-dev": "^0.3.0",
7575
"@types/ini": "^1.3.29",
76-
"@types/jest": "^22.0.1",
76+
"@types/jest": "^22.1.0",
7777
"@types/js-yaml": "^3.10.1",
7878
"@types/lodash.isequal": "^4.5.2",
7979
"@types/node-emoji": "^1.8.0",
@@ -103,7 +103,7 @@
103103
"ts-jsdoc": "^2.0.6",
104104
"tslint": "^5.9.1",
105105
"typescript": "^2.7.0-rc",
106-
"v8-compile-cache": "^1.1.0",
106+
"v8-compile-cache": "^1.1.2",
107107
"whitespace": "^2.1.0",
108108
"worker-farm": "^1.5.2"
109109
},

packages/electron-builder-lib/templates/nsis/include/allowOnlyOneInstallerInstance.nsh

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
!include "nsProcess.nsh"
21
!include "getProcessInfo.nsh"
32

43
# http://nsis.sourceforge.net/Allow_only_one_installer_instance
@@ -26,19 +25,27 @@
2625
!macro CHECK_APP_RUNNING
2726
${GetProcessInfo} 0 $0 $1 $2 $3 $4
2827
${if} $3 != "${APP_EXECUTABLE_FILENAME}"
29-
${nsProcess::FindProcess} "${APP_EXECUTABLE_FILENAME}" $R0
28+
nsProcess::_FindProcess /NOUNLOAD "${APP_EXECUTABLE_FILENAME}"
29+
Pop $R0
30+
nsProcess::_Unload
3031
${If} $R0 == 0
3132
${if} ${isUpdated}
33+
# allow app to exit without explicit kill
34+
Sleep 1000
3235
Goto doStopProcess
3336
${endIf}
3437
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "$(appRunning)" /SD IDOK IDOK doStopProcess
3538
Quit
3639
doStopProcess:
37-
DetailPrint "Closing running ${PRODUCT_NAME} ..."
38-
${nsProcess::KillProcess} "${APP_EXECUTABLE_FILENAME}" $R0
39-
DetailPrint "Waiting for ${PRODUCT_NAME} to close."
40-
Sleep 2000
40+
DetailPrint 'Closing running "${PRODUCT_NAME}"...'
41+
ExecWait 'taskkill /f /t /im "${APP_EXECUTABLE_FILENAME}"' $R0
42+
${If} $R0 == 0
43+
# to ensure that files are not "in-use"
44+
Sleep 100
45+
${else}
46+
DetailPrint 'Waiting for "${PRODUCT_NAME}" to close (taskkill exit code $R0).'
47+
Sleep 2000
48+
${endIf}
4149
${endIf}
42-
${nsProcess::Unload}
4350
${endIf}
4451
!macroend

packages/electron-builder-lib/templates/nsis/include/nsProcess.nsh

Lines changed: 0 additions & 28 deletions
This file was deleted.

packages/electron-builder/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"read-config-file": "2.1.1",
5656
"sanitize-filename": "^1.6.1",
5757
"update-notifier": "^2.3.0",
58-
"yargs": "^10.1.1",
58+
"yargs": "^11.0.0",
5959
"lazy-val": "^1.0.3",
6060
"electron-builder-lib": "0.0.0-semantic-release",
6161
"electron-download-tf": "4.3.4"

yarn.lock

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@
9999
version "1.3.29"
100100
resolved "https://registry.yarnpkg.com/@types/ini/-/ini-1.3.29.tgz#1325e981e047d40d13ce0359b821475b97741d2f"
101101

102-
"@types/jest@^22.0.1":
103-
version "22.0.1"
104-
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-22.0.1.tgz#6370a6d60cce3845e4cd5d00bf65f654264685bc"
102+
"@types/jest@^22.1.0":
103+
version "22.1.0"
104+
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-22.1.0.tgz#c1de03bbac66fac4cc741f7a69cb73bc01a1707c"
105105

106106
"@types/js-yaml@^3.10.1":
107107
version "3.10.1"
@@ -114,8 +114,8 @@
114114
"@types/lodash" "*"
115115

116116
"@types/lodash@*":
117-
version "4.14.93"
118-
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.93.tgz#a6d2a1e1601a3c29196f38ef1990b68a9afa1e1c"
117+
version "4.14.95"
118+
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.95.tgz#02c170690719bbaca8293d9c8cdcccb565728081"
119119

120120
"@types/node-emoji@^1.8.0":
121121
version "1.8.0"
@@ -5023,9 +5023,9 @@ uuid@^3.0.0, uuid@^3.1.0:
50235023
version "3.2.1"
50245024
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.2.1.tgz#12c528bb9d58d0b9265d9a2f6f0fe8be17ff1f14"
50255025

5026-
v8-compile-cache@^1.1.0:
5027-
version "1.1.0"
5028-
resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-1.1.0.tgz#1dc2a340fb8e5f800a32bcdbfb8c23cd747021b9"
5026+
v8-compile-cache@^1.1.0, v8-compile-cache@^1.1.2:
5027+
version "1.1.2"
5028+
resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-1.1.2.tgz#8d32e4f16974654657e676e0e467a348e89b0dc4"
50295029

50305030
validate-npm-package-license@^3.0.1:
50315031
version "3.0.1"
@@ -5292,9 +5292,15 @@ yargs-parser@^8.1.0:
52925292
dependencies:
52935293
camelcase "^4.1.0"
52945294

5295-
yargs@^10.0.3, yargs@^10.1.1:
5296-
version "10.1.1"
5297-
resolved "https://registry.yarnpkg.com/yargs/-/yargs-10.1.1.tgz#5fe1ea306985a099b33492001fa19a1e61efe285"
5295+
yargs-parser@^9.0.2:
5296+
version "9.0.2"
5297+
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-9.0.2.tgz#9ccf6a43460fe4ed40a9bb68f48d43b8a68cc077"
5298+
dependencies:
5299+
camelcase "^4.1.0"
5300+
5301+
yargs@^10.0.3:
5302+
version "10.1.2"
5303+
resolved "https://registry.yarnpkg.com/yargs/-/yargs-10.1.2.tgz#454d074c2b16a51a43e2fb7807e4f9de69ccb5c5"
52985304
dependencies:
52995305
cliui "^4.0.0"
53005306
decamelize "^1.1.1"
@@ -5309,6 +5315,23 @@ yargs@^10.0.3, yargs@^10.1.1:
53095315
y18n "^3.2.1"
53105316
yargs-parser "^8.1.0"
53115317

5318+
yargs@^11.0.0:
5319+
version "11.0.0"
5320+
resolved "https://registry.yarnpkg.com/yargs/-/yargs-11.0.0.tgz#c052931006c5eee74610e5fc0354bedfd08a201b"
5321+
dependencies:
5322+
cliui "^4.0.0"
5323+
decamelize "^1.1.1"
5324+
find-up "^2.1.0"
5325+
get-caller-file "^1.0.1"
5326+
os-locale "^2.0.0"
5327+
require-directory "^2.1.1"
5328+
require-main-filename "^1.0.1"
5329+
set-blocking "^2.0.0"
5330+
string-width "^2.0.0"
5331+
which-module "^2.0.0"
5332+
y18n "^3.2.1"
5333+
yargs-parser "^9.0.2"
5334+
53125335
yargs@^3.32.0:
53135336
version "3.32.0"
53145337
resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.32.0.tgz#03088e9ebf9e756b69751611d2a5ef591482c995"

0 commit comments

Comments
 (0)