Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work properly in Windows #40

Open
joshua-classen opened this issue Apr 14, 2022 · 2 comments
Open

Does not work properly in Windows #40

joshua-classen opened this issue Apr 14, 2022 · 2 comments

Comments

@joshua-classen
Copy link

joshua-classen commented Apr 14, 2022

I spawn a python Process in my Electron App. On the python process runs a Flask server. In my Electron App I spawn the Python process with

const { spawn } = require('child_process');
const treeKill = require('tree-kill');
const path = require('path');

const projectPath = path.join(__dirname, '../');
const pathToPython = path.join(projectPath, '/Venv/Scripts/python');
const pythonOptions = [path.join(projectPath, '/pythonBackend/app.py')];

let ls = spawn(pathToPython, pythonOptions);

I later kill the process with

treeKill(ls.pid);

I can see in the Process Explorer from Microsoft that the tree also gets killed,but after a milisecond, the python process somehow respawns as a standalone process.

If I kill the exact same process tree in the Process Explorer from Windows, then the tree gets killed and there is no crazy respawn of the python process. I don't know why its respawning with the tree-kill module. Any Ideas?

UPDATE
I use now the module tree-kill-promise. https://www.npmjs.com/package/tree-kill-promise This worked for me.

@xxshady
Copy link

xxshady commented Apr 30, 2022

wtf xdddd its basically the same code
https://github.com/dword-design/tree-kill-promise/blob/3d2ca856e1bc3d55d967d9a3eebd516615c086b2/src/index.js#L3

@madaono
Copy link

madaono commented Feb 10, 2023

get the same problems, the java process somehow respawns as a standalone process.
await this.findAvailablePort(PRINT_SERVER_PORT); const childPrintProcess = child_process.spawn('cmd.exe', [ '/c', jrePath, '-jar', '-Dfile.encoding=UTF-8', -Dserver.port=${this.availablePort}`,
'-Ddisable.waiter=merge_table,temp_dish,campaign_dish,old_combo,member_center,full_reduce,charge_quit',
'-Ddisable.link.upgrade=true',
printServicePath,
]);
this.printSocketProcess = childPrintProcess.pid;

// some thing
treeKill(this.printSocketProcess, 'SIGKILL', resolve);
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants