Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is there a way to cause google-chrome to quit, from the terminal, besides using killall google-chrome?
I would like to be able to close it from a script without killing it.

share|improve this question
2  
What is wrong with kill? –  Zoredache Mar 13 '12 at 19:26
    
@Zoredache That it results in different behavior from exiting, and that Chrome uses multiple processes, one of which (the sandbox) is setuid root. –  Gilles Mar 13 '12 at 21:50
add comment

2 Answers 2

up vote 6 down vote accepted

Perhaps wmctrl could be of some assistance. You could use the -c option that closes a window gracefully:

wmctrl -c chrome

The string chrome is matched against the window titles. Note that the window might not close if some message pops-up (e.g. when you have multiple tabs open).

share|improve this answer
    
This option works flawless, but it required the installation of wmctrl. –  slybloty Mar 14 '12 at 0:06
add comment

try:

kill -3 <pid_of_chrome>

This will send a "QUIT" signal to chrome, which, depending on your window manager, will be what it is usually sent when asked to close.

share|improve this answer
2  
This acts just like kill or killall where Chrome sees it as a crash, and asking to restore. –  slybloty Mar 13 '12 at 18:54
1  
try 15 instead of 3, then –  blacklemon67 Mar 13 '12 at 19:40
6  
Actually, SIGQUIT is not usually sent to applications when asked to close (I don't know any WMs that do this). WM_DELETE_WINDOW is the standard. –  Chris Down Mar 13 '12 at 20:29
    
@blacklemon67 kill -15 <pid_of_chrome> did what I was looking for. But, google-chrome has multiple pids and it took a few tried to actually get the right one. –  slybloty Mar 14 '12 at 0:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.