Score:1

A process just won't die

jp flag

For context: I have been playing with stable diffusion on my home server lately, but because my GPU is pretty old, the process often crashes and hangs when I try to go too far. Usually, I'd just kill it with ctrl+C and restart the process. But today,no matter what I do, it seems like the process refuses to die.

I've looked it up a bit, it is not a "zombie" process, both sudo top and ps ux | awk '{if($8=="Z") print}' confirm it, but I cannot kill it with a sudo kill <PID> -9

If it's relevant, the process is a python virtual environment (.venv)

I can, of course, just reboot the whole machine, but I'd like to understand why it's happening, and how to prevent/fix it

Edit: It happened once again, this time I didn't ctrl+C before trying sudo kill <PID> -9 and the process closed quickly. I'm guessing the ctrl+C tries to close the process, but hangs somewhere, so the kill -9 doesn't take effect properly. If someone knows why it happens, I'd still appreciate the explanation

amon avatar
in flag
It is difficult to handle Ctrl-C in Python programs correctly. Some Python programs accidentally ignore the interrupt.
Julien Ripet avatar
jp flag
I see, so is it better to use `kill <PID>` ? Maybe starting with `-15` and going to `-9` if that doesn't work
amon avatar
in flag
A Ctrl-C corresponds to `kill -2` (SIGINT). Just like SIGTERM/15 it can be ignored by the process. SIGKILL/9 should always work because it's handled by the scheduler and never reaches the process, but I have seen delightful kernel bugs where this too failed. If process termination is hanging, this could be an indication that a parent process is waiting for subprocesses to complete. You can inspect subprocess via a command like `pstree -pT <PID>`. Try killing childs before the parent.
Julien Ripet avatar
jp flag
it only returns itself ```pstree -pT 79322``` returns ```python(79322) ```
Zareh Kasparian avatar
us flag
maybe you can use strace command to trace system calls and signals of a process, you can use the command "strace -p PID"
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.