Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

What happens behind the scenes when a user gives a Quit or Force Quit command from outside the target application (e.g. from Activity Monitor)?

share|improve this question

3 Answers 3

up vote 3 down vote accepted

As a general rule, the “Quit” operation is not a signal; it is an Apple Event, which is the same type of IPC used for AppleScript scripting and for opening files or URLs in already-running applications.

However, if you “Quit” a process from Activity Monitor and that process has not registered to receive Apple Events (typically because it has no GUI and/or is a pure Unix program), it will send SIGTERM (15) instead.

share|improve this answer

You can use dtrace to see what signals are sent to processes:

sudo dtrace -n 'proc:::signal-send /pid/ { printf("%s -%d %d", execname, args[2], args[1]->pr_pid); }'

If you force quit an application that is shown in the Dock, the signal is usually -15 (TERM). But if you force quit a background process from Activity Monitor, it is usually -9 (KILL).

share|improve this answer
    
Interesting. How is the distinction made between apps and background processes? –  Blacklight Shining Sep 29 '12 at 0:54
    
I didn't test it with that many processes, but I meant processes that don't have a menu bar or are not shown in the Dock or the force quit window. –  ؘؘؘؘ Sep 29 '12 at 3:05

You can view Force Quit events for GUI applications sent to system.log. Or, use dtrace as posted in this thread. With dtrace you get more granularity but need root privileges.

share|improve this answer
    
-1 (inaccurate): /var/log/system.log doesn't record signals. –  Blacklight Shining Apr 27 '13 at 17:10
    
@BlacklightShining Try launching TextEdit.app and Force Quitting it via Activity Monitor.app. You should see a line like this Apr 28 13:04:21 com.apple.launchd.peruser.501[136] ([0x0-0x3e13e1].com.apple.TextEdit[5336]): Exited: Terminated: 15 It doesn't register the Quit event though. –  1.61803 Apr 28 '13 at 11:15
    
Granted, this works for GUI apps. However, if you start some other process and signal it, it will not be logged. Thus you can't, in general, “view the signals sent” in system.log. –  Blacklight Shining Apr 28 '13 at 11:29
    
@BlacklightShining I emended my post to reflect your comment. –  1.61803 Apr 28 '13 at 11:36

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.