From 5ecadb8512e6b28384ad8c9dd516bda177593353 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Wed, 3 Jun 2026 03:53:14 -0700 Subject: [PATCH] uninstall.ps1: kill llama-server too (pkill self-match made it a no-op) The WSL cleanup ran `pkill -9 -f unsloth_studio` then `pkill -9 -f llama-server`, but the `bash -lc ` shell's own argv contains those literal patterns, so the first pkill SIGKILLed the shell before the llama-server pkill (and trailing `true`) ever ran -- leaving a running llama-server (dynamic port, not covered by `fuser -k 8888`) alive after uninstall. Use the [x]-regex self-exclusion trick ('[u]nsloth_studio' / '[l]lama-server') so the shell's argv no longer contains the matched substring; real target processes still match. Verified in WSL: shell survives, both dummy processes are killed. Co-Authored-By: Claude Opus 4.8 --- scripts/uninstall.ps1 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/uninstall.ps1 b/scripts/uninstall.ps1 index 782cc39290..5dc4052db9 100644 --- a/scripts/uninstall.ps1 +++ b/scripts/uninstall.ps1 @@ -377,7 +377,16 @@ function Uninstall-UnslothStudio { # ~/.local/bin/unsloth -> /bin/unsloth. rm -rf of ~/.unsloth # above deletes its target but leaves the symlink dangling, so the # `unsloth` command still resolves on PATH after an uninstall. - $_clean = 'rm -rf /root/.unsloth /home/*/.unsloth /root/llama-cuda /root/provision_llama_cuda.sh /root/llama_cuda_build.log 2>/dev/null; rm -f /root/.local/bin/unsloth /home/*/.local/bin/unsloth 2>/dev/null; fuser -k 8888/tcp 2>/dev/null; pkill -9 -f unsloth_studio 2>/dev/null; pkill -9 -f llama-server 2>/dev/null; true' + # The pkill patterns use the [x]-regex self-exclusion trick: this very + # `bash -lc ` shell's own argv contains the literal pattern text, so a + # plain `pkill -f unsloth_studio` would match (and SIGKILL) the shell itself + # before the next command runs -- which is why rm goes first AND why the second + # pkill (llama-server, a dynamic port not covered by `fuser -k 8888`) never + # fired. Writing the pattern as '[u]nsloth_studio' means the shell's argv holds + # "[u]nsloth_studio" (no literal "unsloth_studio" substring) so it no longer + # self-matches, while real target processes (cmdline contains "unsloth_studio") + # still match. Same for '[l]lama-server'. + $_clean = 'rm -rf /root/.unsloth /home/*/.unsloth /root/llama-cuda /root/provision_llama_cuda.sh /root/llama_cuda_build.log 2>/dev/null; rm -f /root/.local/bin/unsloth /home/*/.local/bin/unsloth 2>/dev/null; fuser -k 8888/tcp 2>/dev/null; pkill -9 -f ''[u]nsloth_studio'' 2>/dev/null; pkill -9 -f ''[l]lama-server'' 2>/dev/null; true' $_cands = @('', 'Ubuntu', 'Ubuntu-24.04', 'Ubuntu-22.04', 'Debian') if ($env:UNSLOTH_WSL_DISTRO) { $_cands = @($env:UNSLOTH_WSL_DISTRO) + $_cands } $_done = @{}