[GH-ISSUE #5743] process cant't kill on windows 10 #3576

Closed
opened 2026-04-12 14:18:26 -05:00 by GiteaMirror · 5 comments
Owner

Originally created by @wszgrcy on GitHub (Jul 17, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/5743

Originally assigned to: @dhiltgen on GitHub.

What is the issue?

I use child process in node to start ollama,and when I kill process,The process will be partially retained(ollama.exe is killed ollama_llama_server retained)
image
Ubuntu will correctly kill all processes

OS

Windows

GPU

AMD

CPU

AMD

Ollama version

0.2.5

Originally created by @wszgrcy on GitHub (Jul 17, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/5743 Originally assigned to: @dhiltgen on GitHub. ### What is the issue? I use child process in node to start ollama,and when I kill process,The process will be partially retained(`ollama.exe` is killed ollama_llama_server retained) ![image](https://github.com/user-attachments/assets/48d9f7d5-92dc-4357-ac1b-f293b994e788) Ubuntu will correctly kill all processes ### OS Windows ### GPU AMD ### CPU AMD ### Ollama version 0.2.5
GiteaMirror added the bugwindows labels 2026-04-12 14:18:26 -05:00
Author
Owner

@nikhil-swamix commented on GitHub (Jul 17, 2024):

True i can confirm the same

<!-- gh-comment-id:2233124209 --> @nikhil-swamix commented on GitHub (Jul 17, 2024): True i can confirm the same
Author
Owner

@dhiltgen commented on GitHub (Jul 17, 2024):

How are you terminating the tray application? If you gracefully signal the app to exit then it should shutdown the subprocesses. If you forcefully terminate then it has no chance to shutdown the subprocesses.

<!-- gh-comment-id:2234036438 --> @dhiltgen commented on GitHub (Jul 17, 2024): How are you terminating the tray application? If you gracefully signal the app to exit then it should shutdown the subprocesses. If you forcefully terminate then it has no chance to shutdown the subprocesses.
Author
Owner

@wszgrcy commented on GitHub (Jul 18, 2024):

How are you terminating the tray application? If you gracefully signal the app to exit then it should shutdown the subprocesses. If you forcefully terminate then it has no chance to shutdown the subprocesses.

   const process = cp.spawn(`ollama`, ['serve'], { cwd: dir });
// After waiting for the first round of chat
process.kill();

I try to use SIGTERM,SIGHUP,SIGINT,SIGKILL,But none of them killed all processes

<!-- gh-comment-id:2234810137 --> @wszgrcy commented on GitHub (Jul 18, 2024): > How are you terminating the tray application? If you gracefully signal the app to exit then it should shutdown the subprocesses. If you forcefully terminate then it has no chance to shutdown the subprocesses. ```ts const process = cp.spawn(`ollama`, ['serve'], { cwd: dir }); // After waiting for the first round of chat process.kill(); ``` I try to use `SIGTERM`,`SIGHUP`,`SIGINT`,`SIGKILL`,But none of them killed all processes
Author
Owner

@dhiltgen commented on GitHub (Jul 18, 2024):

From your code snippet, I'm guessing that you're using NodeJS and trying to manage the ollama server yourself. Looking around online, it seems the NodeJS implementation of kill may not be fully wired up on Windows, and I see some folks recommending using something like this:

spawn("taskkill", ["/pid", process.pid, '/t']);
<!-- gh-comment-id:2236895651 --> @dhiltgen commented on GitHub (Jul 18, 2024): From your code snippet, I'm guessing that you're using NodeJS and trying to manage the ollama server yourself. Looking around online, it seems the NodeJS implementation of `kill` may not be fully wired up on Windows, and I see some folks recommending using something like this: ``` spawn("taskkill", ["/pid", process.pid, '/t']); ```
Author
Owner

@wszgrcy commented on GitHub (Jul 19, 2024):

From your code snippet, I'm guessing that you're using NodeJS and trying to manage the ollama server yourself. Looking around online, it seems the NodeJS implementation of kill may not be fully wired up on Windows, and I see some folks recommending using something like this:

spawn("taskkill", ["/pid", process.pid, '/t']);

thanks! I use spawn("taskkill", ["/pid", process.pid, '/t','/F']); kill all process

<!-- gh-comment-id:2238045952 --> @wszgrcy commented on GitHub (Jul 19, 2024): > From your code snippet, I'm guessing that you're using NodeJS and trying to manage the ollama server yourself. Looking around online, it seems the NodeJS implementation of `kill` may not be fully wired up on Windows, and I see some folks recommending using something like this: > > ``` > spawn("taskkill", ["/pid", process.pid, '/t']); > ``` thanks! I use `spawn("taskkill", ["/pid", process.pid, '/t','/F']);` kill all process
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#3576