Skip to content

Commit

Permalink
Fixed interrupt app can not kill task.
Browse files Browse the repository at this point in the history
  • Loading branch information
sunquakes committed Jun 12, 2024
1 parent 2fa58c4 commit 522ed1c
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ console.log('NODE_ENV', NODE_ENV)

process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true'

let win

function createWindow() {
const win = new BrowserWindow({
win = new BrowserWindow({
minWidth: 1024,
minHeight: 768,
webPreferences: {
Expand Down Expand Up @@ -61,3 +63,29 @@ app.on('window-all-closed', () => {
app.quit()
}
})

const handleTerminationSignals = () => {
if (win) {
win.close()
}
app.quit()
}

if (process.platform === 'win32') {
require('readline')
.createInterface({
input: process.stdin,
output: process.stdout
})
.on('SIGINT', () => {
handleTerminationSignals()
})
}

process.on('SIGINT', () => {
handleTerminationSignals()
})

process.on('SIGTERM', () => {
handleTerminationSignals()
})

0 comments on commit 522ed1c

Please sign in to comment.