Apart from the SAK Magic SysRq sequence does anyone know of a way to kill all the processes that have a particular virtual console open?
TiA, Steve.
Hi,
2009/1/20 Steve Fosdick lists@pelvoux.nildram.co.uk:
Apart from the SAK Magic SysRq sequence does anyone know of a way to kill all the processes that have a particular virtual console open?
Some combination of lsof, grep, awk, and kill ?
Srdjan
On 20 Jan 12:15, Srdjan Todorovic wrote:
Hi,
2009/1/20 Steve Fosdick lists@pelvoux.nildram.co.uk:
Apart from the SAK Magic SysRq sequence does anyone know of a way to kill all the processes that have a particular virtual console open?
Some combination of lsof, grep, awk, and kill ?
How about...
brettp@miranda:~$ ps -t pts/3 --format 'pid' --no-headers 2243 22355 brettp@miranda:~$ ps -t pts/3 PID TTY TIME CMD 2243 pts/3 00:00:00 bash 22355 pts/3 00:00:04 w3m brettp@miranda:~$
Where pts/3 is the owning terminal in this case...
so you could do: ps -t pts/3 --format 'pid' --no-headers | xargs kill
Cheers,
On Tue, 2009-01-20 at 12:46 +0000, Brett Parker wrote:
On 20 Jan 12:15, Srdjan Todorovic wrote:
Hi,
2009/1/20 Steve Fosdick lists@pelvoux.nildram.co.uk:
Apart from the SAK Magic SysRq sequence does anyone know of a way to kill all the processes that have a particular virtual console open?
Some combination of lsof, grep, awk, and kill ?
How about...
brettp@miranda:~$ ps -t pts/3 --format 'pid' --no-headers 2243 22355 brettp@miranda:~$ ps -t pts/3 PID TTY TIME CMD 2243 pts/3 00:00:00 bash 22355 pts/3 00:00:04 w3m brettp@miranda:~$
Where pts/3 is the owning terminal in this case...
I'd tried using fuser and specifying /dev/tty7 as the file to check but this produced no output at all.
IIRC the ps command in this case only lists programs which have that tty device as their controlling terminal. Although most programs that have a tty open will have as the controlling terminal this is not guaranteed.
The particular situation that lead up to this was that I was logged into GNOME, clicked the logout launcher in the panel and then found that GNOME clearly thought it was logging out as it wouldn't start any new programs but the logout didn't seem to be happening. The only programs visible were nautilus and the panel but 'ps' from a text console showed quite a few others.
I had nothing I had not saved so I did the 'Kill X' sequence Ctl-Alt-Backspace which did the trick but when gdm started an X server to replace the killed one it used virtual console 9 instead of the usual 7 (there as another one running on 8). Wondering why I tried deallocvt on 7 and it claimed it was busy, hence trying to work out what was still using it and how to kill it.
In the end stopping gdm and restarting it freed the virtual console so it must have been some part of gdm or a child thereof but it did not show up in ps or fuser which is why I am puzzled.
Regards, Steve.