I've written a python script which does some curses and pysqlite stuff, but I've noticed that in occasions where I've been running this script over ssh when that ssh session is killed for whatever reason the python script doesn't actually exit, instead it ends up as being a child of init and just stays there forever. I can't kill -9 them or anything. They also increase the reported system load by 1. Currently I have 8 of these mostly dead processes hanging around, and the server has a load average of 8.abit. I take it this is because there is some sort of resource that these scripts are waiting on, but lsof shows nothing actually open by them, all data files they were using are listed as deleted etc... and they are using no cpu time whatsoever.
I'm doing some signal checking in the script, calling out to do some refresh routines on a HUP, but nothing else, not forking or anything and I'm at a loss as to why the scripts are not just shuffling off when I close my ssh session.
Thanks  Chris
Well, the reason they're not shutting down when your ssh session terminates is because HUP is the signal used by a parent to inform its children that they should shut down. If you're overriding the behavior of this signal, then your processes will not automatically shut down when the SSH session is closed. As for why you cannot kill -9 them, however, I'm at a loss. The only thing I've seen that causes that behavior is processes blocked on misbehaving filesystems (nfs & unionfs being the two I've encountered the problem with).
Python scripts (curses + pysqlite) hanging after parent shell goes away