mirror of
https://github.com/atom/atom.git
synced 2026-01-24 06:18:03 -05:00
Merge pull request #16668 from Connormiha/optimize-kill-process
Optimize process kill by pid
This commit is contained in:
@@ -189,12 +189,12 @@ class BufferedProcess {
|
||||
output += data
|
||||
})
|
||||
wmicProcess.stdout.on('close', () => {
|
||||
const pidsToKill = output.split(/\s+/)
|
||||
.filter((pid) => /^\d+$/.test(pid))
|
||||
.map((pid) => parseInt(pid))
|
||||
.filter((pid) => pid !== parentPid && pid > 0 && pid < Infinity)
|
||||
for (let pid of output.split(/\s+/)) {
|
||||
if (!/^\d{1,10}$/.test(pid)) continue
|
||||
pid = parseInt(pid, 10)
|
||||
|
||||
if (!pid || pid === parentPid) continue
|
||||
|
||||
for (let pid of pidsToKill) {
|
||||
try {
|
||||
process.kill(pid)
|
||||
} catch (error) {}
|
||||
|
||||
Reference in New Issue
Block a user