Skip to content

Commit

Permalink
fix: NSIS uninstaller doesn't kill child processes
Browse files Browse the repository at this point in the history
Close #2516
  • Loading branch information
develar committed Jan 24, 2018
1 parent c6f96d3 commit ad199c4
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 50 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@
"temp-file": "^3.1.1",
"tunnel-agent": "^0.6.0",
"update-notifier": "^2.3.0",
"yargs": "^10.1.1"
"yargs": "^11.0.0"
},
"devDependencies": {
"@develar/gitbook": "3.2.11",
"@types/debug": "^0.0.30",
"@types/ejs": "^2.5.0",
"@types/electron-is-dev": "^0.3.0",
"@types/ini": "^1.3.29",
"@types/jest": "^22.0.1",
"@types/jest": "^22.1.0",
"@types/js-yaml": "^3.10.1",
"@types/lodash.isequal": "^4.5.2",
"@types/node-emoji": "^1.8.0",
Expand Down Expand Up @@ -103,7 +103,7 @@
"ts-jsdoc": "^2.0.6",
"tslint": "^5.9.1",
"typescript": "^2.7.0-rc",
"v8-compile-cache": "^1.1.0",
"v8-compile-cache": "^1.1.2",
"whitespace": "^2.1.0",
"worker-farm": "^1.5.2"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
!include "nsProcess.nsh"
!include "getProcessInfo.nsh"

# http://nsis.sourceforge.net/Allow_only_one_installer_instance
Expand Down Expand Up @@ -26,19 +25,27 @@
!macro CHECK_APP_RUNNING
${GetProcessInfo} 0 $0 $1 $2 $3 $4
${if} $3 != "${APP_EXECUTABLE_FILENAME}"
${nsProcess::FindProcess} "${APP_EXECUTABLE_FILENAME}" $R0
nsProcess::_FindProcess /NOUNLOAD "${APP_EXECUTABLE_FILENAME}"
Pop $R0
nsProcess::_Unload
${If} $R0 == 0
${if} ${isUpdated}
# allow app to exit without explicit kill
Sleep 1000
Goto doStopProcess
${endIf}
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "$(appRunning)" /SD IDOK IDOK doStopProcess
Quit
doStopProcess:
DetailPrint "Closing running ${PRODUCT_NAME} ..."
${nsProcess::KillProcess} "${APP_EXECUTABLE_FILENAME}" $R0
DetailPrint "Waiting for ${PRODUCT_NAME} to close."
Sleep 2000
DetailPrint 'Closing running "${PRODUCT_NAME}"...'
ExecWait 'taskkill /f /t /im "${APP_EXECUTABLE_FILENAME}"' $R0
${If} $R0 == 0
# to ensure that files are not "in-use"
Sleep 100
${else}
DetailPrint 'Waiting for "${PRODUCT_NAME}" to close (taskkill exit code $R0).'
Sleep 2000
${endIf}
${endIf}
${nsProcess::Unload}
${endIf}
!macroend
28 changes: 0 additions & 28 deletions packages/electron-builder-lib/templates/nsis/include/nsProcess.nsh

This file was deleted.

2 changes: 1 addition & 1 deletion packages/electron-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"read-config-file": "2.1.1",
"sanitize-filename": "^1.6.1",
"update-notifier": "^2.3.0",
"yargs": "^10.1.1",
"yargs": "^11.0.0",
"lazy-val": "^1.0.3",
"electron-builder-lib": "0.0.0-semantic-release",
"electron-download-tf": "4.3.4"
Expand Down
45 changes: 34 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@
version "1.3.29"
resolved "https://registry.yarnpkg.com/@types/ini/-/ini-1.3.29.tgz#1325e981e047d40d13ce0359b821475b97741d2f"

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

"@types/js-yaml@^3.10.1":
version "3.10.1"
Expand All @@ -114,8 +114,8 @@
"@types/lodash" "*"

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

"@types/node-emoji@^1.8.0":
version "1.8.0"
Expand Down Expand Up @@ -5023,9 +5023,9 @@ uuid@^3.0.0, uuid@^3.1.0:
version "3.2.1"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.2.1.tgz#12c528bb9d58d0b9265d9a2f6f0fe8be17ff1f14"

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

validate-npm-package-license@^3.0.1:
version "3.0.1"
Expand Down Expand Up @@ -5292,9 +5292,15 @@ yargs-parser@^8.1.0:
dependencies:
camelcase "^4.1.0"

yargs@^10.0.3, yargs@^10.1.1:
version "10.1.1"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-10.1.1.tgz#5fe1ea306985a099b33492001fa19a1e61efe285"
yargs-parser@^9.0.2:
version "9.0.2"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-9.0.2.tgz#9ccf6a43460fe4ed40a9bb68f48d43b8a68cc077"
dependencies:
camelcase "^4.1.0"

yargs@^10.0.3:
version "10.1.2"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-10.1.2.tgz#454d074c2b16a51a43e2fb7807e4f9de69ccb5c5"
dependencies:
cliui "^4.0.0"
decamelize "^1.1.1"
Expand All @@ -5309,6 +5315,23 @@ yargs@^10.0.3, yargs@^10.1.1:
y18n "^3.2.1"
yargs-parser "^8.1.0"

yargs@^11.0.0:
version "11.0.0"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-11.0.0.tgz#c052931006c5eee74610e5fc0354bedfd08a201b"
dependencies:
cliui "^4.0.0"
decamelize "^1.1.1"
find-up "^2.1.0"
get-caller-file "^1.0.1"
os-locale "^2.0.0"
require-directory "^2.1.1"
require-main-filename "^1.0.1"
set-blocking "^2.0.0"
string-width "^2.0.0"
which-module "^2.0.0"
y18n "^3.2.1"
yargs-parser "^9.0.2"

yargs@^3.32.0:
version "3.32.0"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.32.0.tgz#03088e9ebf9e756b69751611d2a5ef591482c995"
Expand Down

1 comment on commit ad199c4

@IDrinkMoreWater
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi,This change brought a new bug. It happens when autoupdate ;“taskkill /f /t “ ,This will kill the installation process,Because the installation process is the main application of the child processes.

As shown:

pid-2028 is a child processes of pid-3044,pid-2028 is installation process,pid-3044 is main application

qq 20180306125457
qq 20180306125552

Please sign in to comment.