2

Sometimes I need to kill Google Chrome (of which I have 2 windows/instances opened). Both instances are not in incognito mode.

What I do is: (on Debian 8)

killall chrome && killall chrome

to have 2 windows of chrome closed.

However I read that killall command should kill all instances of a program, not just one.

So I was wondering: why killall doesn't kill all instances as the name would suggest?

dragonmnl
  • 2,239
  • 1
    killall does not mean "kill all these processes" but "send the (implicitly) specified signal to all these processes". See this question: http://unix.stackexchange.com/questions/85364/how-can-i-check-what-signals-a-process-is-listening-to – Hauke Laging Jan 26 '16 at 02:56
  • If you want to kill all Chrome instances you only need to kill the first process which spawned all other Chrome threads. It will have a parent process id of 1. Try pkill -P1 chrome and see if that does what you wish. – bsd Jan 26 '16 at 12:39

4 Answers4

2

I tried it with 2 processes and it seems to work as follows:

jai@jai-VirtualBox:/tmp$ sleep 100 &
[1] 3996
jai@jai-VirtualBox:/tmp$ sleep 60 &
[2] 3997
jai@jai-VirtualBox:/tmp$ pgrep -l sleep
3996 sleep
3997 sleep
jai@jai-VirtualBox:/tmp$ killall -v sleep
Killed sleep(3996) with signal 15
Killed sleep(3997) with signal 15
[1]-  Terminated              sleep 100
[2]+  Terminated              sleep 60

jai@jai-VirtualBox:/tmp$ pgrep -l sleep jai@jai-VirtualBox:/tmp$

Could you try again with either -v (verbose) or -i (interactive)?

Manuel Jordan
  • 1,728
  • 2
  • 16
  • 40
jai_s
  • 1,500
  • thanks for your answer. I didn't get the purpose of sleep. Shall I try killall -i chrome without any other parameter? – dragonmnl Jan 26 '16 at 11:58
  • 1
    sleep was just used to create a process (shell runs the sleep command) here. You could use any command that runs for a while - so that you get some time to kill it. You could try killall with the -v option to get more info. You could use -i to run it interactively (it should ask for input in the -i case). – jai_s Jan 26 '16 at 17:31
1

you can use the command top to show process

top

to kill process

 kill PID_of_chrome
GAD3R
  • 66,769
1

Chrome browser spawns several threads at startup then spawns extra threads for each window and/or tab created subsequently.

By default, killall sends a SIGTERM to all processed having a specific name ("chrome" in your case). But only the processes able to handle this signal will proceed with it. The ones that are not able to handle SIGTERM signal won't close. You can kill them unconditionally with a killall -9

  • so, killall -9 chrome would kill all the instances, no matter if they handle or not the kill signal? Also, why would Chrome show "unexpected close" on next startup if it's actually the process to choose if accepting or not to be killed? (If I got it right?) – dragonmnl Jan 26 '16 at 11:57
  • Chromium occasionally restarts with "unexpected close" even when closed properly. – bsd Jan 26 '16 at 12:24
  • killall -9 is a rather brutal way to end a process. From a process perspective it's quite comparable to crashing the process. "unexpected close" messages are just a way for Chrome to tell that things did not end nicely on previous session. – Olivier Dauby Jan 27 '16 at 14:16
0

It is possible that one of the chrome instances is ignoring the SIGTERM signal, waiting for a second to confirm? killall -9 chrome may do what you want.

zje
  • 2,311