Personal computing discussed

Moderators: renee, SecretSquirrel, notfred

 
Madman
Minister of Gerbil Affairs
Topic Author
Posts: 2317
Joined: Tue Apr 01, 2003 4:55 am
Location: Latvia

How to do a reliable taskkill under Linux

Fri Aug 24, 2012 10:14 pm

I have been using Linux quite some time, and I'm very happy overall, but there is one issue that bugs me all the time.

The problem is unresponsive tasks... For example, Wine sometimes tends to freeze completely while launching some app.

And this is where things go very wrong, very fast. Alt+ctrl+del does nothing, shift+alt+ctrl+f1 does nothing, alt+tab is very spotty and usually freezes at some point. So basically system is effectively disabled by a user space application.

The best what I can do is to hold Alt+SysRq and type REISUB, which reboots the PC. But this is still awfull from my point of view.

Does anyone know if there a way to get some Windows like taskkill that gets into front even if it has to page out gigabytes of data and takes a few hours?

The system in question is Mint 13 amd64, but this can probably be tied to other distributions as well.
Core 2 Duo E6300, MSI P45 NEO-F, Club 3D GTX 260, 4Gb DDR2-800Mhz, Audigy X-Fi Fatal1ty Champ1on ed., 0.5Tb+1Tb Seagate Barracuda 7200.12, 630W AXP, Samsung SyncMaster BX2450, ViewSonic VP171b
 
bthylafh
Maximum Gerbil
Posts: 4320
Joined: Mon Dec 29, 2003 11:55 pm
Location: Southwest Missouri, USA

Re: How to do a reliable taskkill under Linux

Fri Aug 24, 2012 10:26 pm

In a terminal:
ps ax | grep -i [programname]

for example:
ps ax | grep -i wine

You're looking for the first column of the returned value, say 2483 (this is the process ID). Now type
kill -term 2483
and it'll send SIGTERM to wine, which (assuming it can receive any signals) will cause Wine to terminate gracefully. If not, you can type
kill -9 2483
and it'll try to terminate Wine with prejudice, without giving it a chance to save its data files. If this /still/ doesn't work, as a last resort you can try
sudo kill -9 2483
and it'll ask you for your password. Now it'll kill Wine from a higher privilege level, which it should be unable to ignore.
Hakkaa päälle!
i7-8700K|Asus Z-370 Pro|32GB DDR4|Asus Radeon RX-580|Samsung 960 EVO 1TB|1988 Model M||Logitech MX 518 & F310|Samsung C24FG70|Dell 2209WA|ATH-M50x
 
ChronoReverse
Gerbil Elite
Posts: 757
Joined: Wed Dec 12, 2007 4:20 pm

Re: How to do a reliable taskkill under Linux

Fri Aug 24, 2012 10:26 pm

The Number 9 Kill is close to invincible!
 
chuckula
Minister of Gerbil Affairs
Posts: 2109
Joined: Wed Jan 23, 2008 9:18 pm
Location: Probably where I don't belong.

Re: How to do a reliable taskkill under Linux

Fri Aug 24, 2012 10:34 pm

You can also do the "pkill" version of the kill command that takes a string corresponding to all or part of the process you want killed and doesn't require you to enter the numeric process ID. One caveat of pkill is that you want to be careful about the text term you put in being too broad.

For a contrived example, I have two background services called "dbus-launch" and "dbus-daemon" running right now. If I just do "pkill dbus" then both processes would get killed, even if I only really wanted "dbus-launch" killed. A way of checking which process will be killed is to simply run the "pgrep" command before pkill and make sure that the results of pgrep only include one or more processes you want dead.
4770K @ 4.7 GHz; 32GB DDR3-2133; Officially RX-560... that's right AMD you shills!; 512GB 840 Pro (2x); Fractal Define XL-R2; NZXT Kraken-X60
--Many thanks to the TR Forum for advice in getting it built.
 
Madman
Minister of Gerbil Affairs
Topic Author
Posts: 2317
Joined: Tue Apr 01, 2003 4:55 am
Location: Latvia

Re: How to do a reliable taskkill under Linux

Fri Aug 24, 2012 10:44 pm

The problem is that I cannot get to the console. Alt+Ctrl+t doesn't work. Whole desktop is captured by Wine or other misbehaving program, and even shortcut to clean terminal session - alt+ctrl+shift+f1 doesn't do anything.

I know about kill or killall, but I cannot launch them :(
Core 2 Duo E6300, MSI P45 NEO-F, Club 3D GTX 260, 4Gb DDR2-800Mhz, Audigy X-Fi Fatal1ty Champ1on ed., 0.5Tb+1Tb Seagate Barracuda 7200.12, 630W AXP, Samsung SyncMaster BX2450, ViewSonic VP171b
 
just brew it!
Administrator
Posts: 54500
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Re: How to do a reliable taskkill under Linux

Fri Aug 24, 2012 11:11 pm

If you've got another PC on the network maybe you could start a remote terminal session via SSH and kill the process from there? I agree this is a rather non-optimal solution though. In my experience it's pretty rare that Ctrl-Alt-F1 to bring up a bare console doesn't work.
Nostalgia isn't what it used to be.
 
PenGun
Gerbil Elite
Posts: 893
Joined: Fri Jun 18, 2004 1:48 pm
Location: BC Canada
Contact:

Re: How to do a reliable taskkill under Linux

Sat Aug 25, 2012 12:41 am

You could set it up so Alt-Ctl-Backspace drops you to the console, killing off X. My Slackware dist is always set up that way. You can also change to a console with Alt-Ctl-F1 to F6 with F7 returning you to your X session.

But if you have lost the keyboard you are pretty well toast. Hardware button time, or surf in from another machine.
Fuji X-E1 Leica Elmar 135 4 XF60mm 2.4 Macro | Zeiss FE 35mm 2.8
http://carnagepro.com
"Everything ... they eat everything, and fear is their bacon bits."
 
Zoomastigophora
Gerbil Elite
Posts: 667
Joined: Tue Nov 11, 2008 7:10 pm

Re: How to do a reliable taskkill under Linux

Sat Aug 25, 2012 2:04 am

PenGun wrote:
You could set it up so Alt-Ctl-Backspace drops you to the console, killing off X. My Slackware dist is always set up that way. You can also change to a console with Alt-Ctl-F1 to F6 with F7 returning you to your X session.

But if you have lost the keyboard you are pretty well toast. Hardware button time, or surf in from another machine.

This. Forever this. I don't understand how X server hasn't been replaced with something better, but I've had misbehaving programs completely eat up UI responsiveness, which prevents you from launching a console since those technically become windowed and X server is likely choking on whatever application has focus. In those situations, nuking X server completely from a command shortcut has been the saving grace from needing to reboot and losing too much work. I learned this the hard way after rolling my own Gentoo installations several times. Thankfully, Gentoo boots into a CLI by default which is usable and what it falls back to when X dies. I know some distros with a default GUI just immediately relaunch X if its killed, which I'm not a huge fan of because I've had that freeze up due to the previous X session not having exited fully.
 
bthylafh
Maximum Gerbil
Posts: 4320
Joined: Mon Dec 29, 2003 11:55 pm
Location: Southwest Missouri, USA

Re: How to do a reliable taskkill under Linux

Sat Aug 25, 2012 9:37 am

Re-enable ctrl-alt-backspace to kill X:
http://ihaveapc.com/2011/12/how-to-enab ... -x-server/

ctrl-alt-esc should invoke xkill, which will let you click on a program to terminate.
Hakkaa päälle!
i7-8700K|Asus Z-370 Pro|32GB DDR4|Asus Radeon RX-580|Samsung 960 EVO 1TB|1988 Model M||Logitech MX 518 & F310|Samsung C24FG70|Dell 2209WA|ATH-M50x
 
Madman
Minister of Gerbil Affairs
Topic Author
Posts: 2317
Joined: Tue Apr 01, 2003 4:55 am
Location: Latvia

Re: How to do a reliable taskkill under Linux

Sat Aug 25, 2012 9:42 am

bthylafh wrote:
Re-enable ctrl-alt-backspace to kill X:
http://ihaveapc.com/2011/12/how-to-enab ... -x-server/

Thank you! A very usefull information here. Also fixes alt+shift keyboard layout switching which I was missing :)
Core 2 Duo E6300, MSI P45 NEO-F, Club 3D GTX 260, 4Gb DDR2-800Mhz, Audigy X-Fi Fatal1ty Champ1on ed., 0.5Tb+1Tb Seagate Barracuda 7200.12, 630W AXP, Samsung SyncMaster BX2450, ViewSonic VP171b

Who is online

Users browsing this forum: Google [Bot] and 1 guest
GZIP: On