Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 1. pyProc.kill() does not work due to SIGTERM not really being a signal
// in Windows
// 2. the onefile pyinstaller packaging creates two executables.
// https://github.com/pyinstaller/pyinstaller/issues/2483
//
// So the solution is to not let the application close, get all
// pids and kill them before we close the app
this.logToFile('Starting windows process termination');
const executable = this.executable;
if (!executable) {
this.logToFile('No python sub-process executable detected');
return;
}
const tasks: tasklist.Task[] = await tasklist();
this.logToFile(`Currently running: ${tasks.length} tasks`);
const pids = tasks
.filter(task => task.imageName === executable)
.map(task => task.pid);
this.logToFile(
`Detected the following running python sub-processes: ${pids.join(', ')}`
);
const args = ['/f', '/t'];
for (let i = 0; i < pids.length; i++) {
args.push('/PID');
args.push(pids[i].toString());
}
async scan () {
const emulators = (await tasklist()).filter(el => el.imageName.includes('Project64')).map(el => ({
name: el.imageName,
pid: el.pid
}))
this.setState({
emulators
})
}
async onSelectEmulator (e) {