Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Another way (better?)' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Another way (better?)
Authored by: jolinwarren on Jan 23, '04 03:43:27PM
Actually, I would suggest that the 'cleanest' way to restart the Finder is to use the following command:

osascript -e 'tell app "Finder" to quit'
You can then relaunch the Finder by clicking its icon in the Dock. The advantage of this is that you are sending the Finder the standard "Quit" AppleEvent, which is the native way of communicating with Mac applications, so the Finder should do any clean-up necessary before quitting.

[ Reply to This | # ]
Another way (better?)
Authored by: makip on Mar 27, '05 10:48:39PM
That AppleScript has the same effect as choosing the Quit menu item in the application, which I dont believe will work for a non-responsive application. The following command sends the default TERM signal:
killall Finder
The available signals for stopping a progam, in order of niceness are TERM, QUIT, KILL.
killall -QUIT Finder
killall -KILL Finder
If the TERM fails to terminate a program, the next step would be to try QUIT. If the program does not respond to QUIT either, then as a last resort the KILL signal should be used. KILL cannot be ignored by a program, the operating system will terminate it immediately. TERM and QUIT are designed to give a process the chance to clean up before exiting, whereas KILL will stop the process whatever it may be doing.

You can see a list of all signals (not all are for killing) with kill -l. A summary of the ones for killing a program are:
HUP Hangup - stop running. Sent when you log out or disconnect a modem
INT Interrupt - stop running. Sent when you type CTRL-c
QUIT Quit - stop running (and dump core). Sent when you type CTRL-\
KILL Kill - stop unconditionally and immediately; "emergency kill."
TERM Terminate - terminate gracefully, if possible
STOP Stop unconditionally and immediately; continue with CONT
CONT Continue - continue executing after STOP or TSTP
The kill command is named because of the nature of the default TERM signal, but in general it's used to send a variety of signals to programs. There are summaries on the man pages man kill and man killall but they're not very useful to learn from. Better descriptions can be found by googling something like "unix signals kill term quit".

Having said all that, if I want to re-launch my Finder while it is still responding, I like to use option+click & hold on the Finder dock icon, then select re-launch, as described elsewhere on this page.

regards, Maki.

[ Reply to This | # ]