Re: Quitting all active applications
On Thu, Aug 28, 2008 at 1:52 PM, Martin Stoufer [EMAIL PROTECTED] wrote: I had always naively assumed that all the some *Framework underneath an app was setting up signal handlers for you with default behaviours. If this isn't the case, then yes any killall approach will cause loss of data. Now I'm interested into finding out why this isn't the case. Signals are a very poor mechanism for this. Apple Events provide two important semantics: 1) They allow for an I'm finished reply. This allows the sender to find out when the target is done with its business, so that it can allow the sender to take a tenth of a second or a hundred seconds as it needs. 2) They allow for an I'm not ready to quit yet reply. You'll see this in action if you try to log out when you have unsaved documents in an application, and you click Cancel when it asks you whether you want to save. Signals don't support either of these. For #1, the standard technique is to do a SIGTERM, wait one second, then do a SIGKILL to anybody who's still left alive. This is less than ideal for what should be obvious reasons. For #2, the possibility that a target might abort the action is simply ignored. Targets die when they are killed, end of story. Consider what happens when you send a quit Apple Event to TextEdit when you have an unsaved document open. You get a nice window asking if you want to save, and letting you cancel. Now compare with what happens when you send SIGTERM to pico or emacs with an unsaved document open. They terminate instantaneously and take all of your work down with them. Now, there's nothing preventing the frameworks from installing a handler for SIGTERM and closing down more gracefully. But the convention is for SIGTERM to kill you very quickly, and a process is only expected to clean up critical resources that might otherwise be corrupted. Since a mechanism already exists for the user-friendly quit, there's not too much point in changing the meaning of SIGTERM as well. Mike ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Quitting all active applications
Is there a simple way to quit all running applications? Basically I want to achieve the same result as the first stage of hitting 'shut down' (closing all applications) without actually shutting down the system. Thanks. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Quitting all active applications
On 28/08/2008, at 8:36 PM, Phil Faber wrote: Is there a simple way to quit all running applications? Basically I want to achieve the same result as the first stage of hitting 'shut down' (closing all applications) without actually shutting down the system. You could get the launched applications by using [[NSWorkspace sharedWorkspace] launchedApplications] and then send each of them a Quit Apple Event. But why would you want to do this? It is possibly one of the most annoying things you could do to someone's machine and you would want to have a very, very good reason for it. -- Rob Keniger ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Quitting all active applications
On Thu, Aug 28, 2008 at 10:36 PM, Phil Faber [EMAIL PROTECTED] wrote: Is there a simple way to quit all running applications? Basically I want to achieve the same result as the first stage of hitting 'shut down' (closing all applications) without actually shutting down the system. What do you mean by all running applications? There are GUI applications, background daemons owned by the user, applications of other users, system processes, etc. Also, what do you mean by quit? Do you want to force quit them, or tell them to gracefully quit? (During the shutdown process, applications have the opportunity to cancel the event). And depending on the type of application, the preferred way of getting them to quit changes. What are you trying to achieve here? I would suggest reading Apple's documentation of the shutdown process at: http://developer.apple.com/DOCUMENTATION/MacOSX/Conceptual/BPSystemStartup/Articles/BootProcess.html Phil ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Quitting all active applications
28 aug 2008 kl. 12.36 skrev Phil Faber: Is there a simple way to quit all running applications? Basically I want to achieve the same result as the first stage of hitting 'shut down' (closing all applications) without actually shutting down the system. Take a look at the NSWorkspace class. The launchedApplications: method will give you an array of running applications including their process id. A simple solution would be to use NSTask to invoke the kill command on each of them. Just remember to remove you application from the array or it will be killed as well. By the way, in what situation do you want to kill all running applications? Marcus smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Quitting all active applications
Yes I agree it could be most annoying in the majority of cases to quit other people's apps! All I'm trying to achieve is a tiny app that only quits open apps and then quits itself; the purpose being when I want to release as much memory and disc space as possible before I run another memory / processor intensive app. I could just quit each one individually but I guess I'm lazy! I'm not suggesting anything more sinister! Thanks to you everyone for the advice. Phil On 28 Aug 2008, at 12:12, Rob Keniger wrote: On 28/08/2008, at 8:36 PM, Phil Faber wrote: Is there a simple way to quit all running applications? Basically I want to achieve the same result as the first stage of hitting 'shut down' (closing all applications) without actually shutting down the system. You could get the launched applications by using [[NSWorkspace sharedWorkspace] launchedApplications] and then send each of them a Quit Apple Event. But why would you want to do this? It is possibly one of the most annoying things you could do to someone's machine and you would want to have a very, very good reason for it. -- Rob Keniger ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Quitting all active applications
A small app that utilized an NSTask object whose system command would be 'killall -u your short username here -m regex'. Where the regex would probably exclude processes that did not include 'login' or anything 'launchd'. This would keep the reaper from killing your loginwindow process as well! Phil Faber wrote: Yes I agree it could be most annoying in the majority of cases to quit other people's apps! All I'm trying to achieve is a tiny app that only quits open apps and then quits itself; the purpose being when I want to release as much memory and disc space as possible before I run another memory / processor intensive app. I could just quit each one individually but I guess I'm lazy! I'm not suggesting anything more sinister! Thanks to you everyone for the advice. Phil On 28 Aug 2008, at 12:12, Rob Keniger wrote: On 28/08/2008, at 8:36 PM, Phil Faber wrote: Is there a simple way to quit all running applications? Basically I want to achieve the same result as the first stage of hitting 'shut down' (closing all applications) without actually shutting down the system. You could get the launched applications by using [[NSWorkspace sharedWorkspace] launchedApplications] and then send each of them a Quit Apple Event. But why would you want to do this? It is possibly one of the most annoying things you could do to someone's machine and you would want to have a very, very good reason for it. -- Rob Keniger ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/mcstoufer%40lbl.gov This email sent to [EMAIL PROTECTED] -- * Martin C. Stoufer * * ISS/IT * * Lawrence Berkeley National Lab * * 510-486-5306 * * MS 937-700 * smime.p7s Description: S/MIME Cryptographic Signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Quitting all active applications
Actually no, since the default kill signal is TERM, apps will be allowed to prompt to save if necessary. This assumes the app is handling that signal properly. We could send KILL or ABRT and that would just end the processes w/o any save options. Randall Meadows wrote: On Aug 28, 2008, at 10:46 AM, Martin Stoufer wrote: A small app that utilized an NSTask object whose system command would be 'killall -u your short username here -m regex'. And that would be a great way to lose data, if any of the applications getting killed had unsaved documents. -- * Martin C. Stoufer * * ISS/IT * * Lawrence Berkeley National Lab * * 510-486-5306 * * MS 937-700 * smime.p7s Description: S/MIME Cryptographic Signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Quitting all active applications
GUI applications do not generally handle SIGTERM (or any other signals for that matter). Killing GUI applications is a Bad Thing™ :) Randal is correct, this will lose your saved data in any currently open applications. On Thu, Aug 28, 2008 at 10:39 AM, Martin Stoufer [EMAIL PROTECTED] wrote: Actually no, since the default kill signal is TERM, apps will be allowed to prompt to save if necessary. This assumes the app is handling that signal properly. We could send KILL or ABRT and that would just end the processes w/o any save options. Randall Meadows wrote: On Aug 28, 2008, at 10:46 AM, Martin Stoufer wrote: A small app that utilized an NSTask object whose system command would be 'killall -u your short username here -m regex'. And that would be a great way to lose data, if any of the applications getting killed had unsaved documents. -- * Martin C. Stoufer * * ISS/IT * * Lawrence Berkeley National Lab * * 510-486-5306 * * MS 937-700 * ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/clarkcox3%40gmail.com This email sent to [EMAIL PROTECTED] -- Clark S. Cox III [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Quitting all active applications
Cocoa Application expects a Quit AppleEvent, not a sigterm. SIGTERM will kill the app and it will not have any chance to save the edited document. Try with TextEdit if you don't belive it ;-) Actually no, since the default kill signal is TERM, apps will be allowed to prompt to save if necessary. This assumes the app is handling that signal properly. We could send KILL or ABRT and that would just end the processes w/o any save options. Randall Meadows wrote: On Aug 28, 2008, at 10:46 AM, Martin Stoufer wrote: A small app that utilized an NSTask object whose system command would be 'killall -u your short username here -m regex'. And that would be a great way to lose data, if any of the applications getting killed had unsaved documents. -- * Martin C. Stoufer * * ISS/IT * * Lawrence Berkeley National Lab * * 510-486-5306 * * MS 937-700 * ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/devlists%40shadowlab.org This email sent to [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Quitting all active applications
On Aug 28, 2008, at 11:39 AM, Martin Stoufer wrote: Actually no, since the default kill signal is TERM, apps will be allowed to prompt to save if necessary. This assumes the app is handling that signal properly. We could send KILL or ABRT and that would just end the processes w/o any save options. Well, then there must be a lot of apps out there that don't handle it properly. TextEdit, Pages, Word, Omnigraffle all failed to prompt me to save dirty documents when I used killall on them. Granted, that's a small data sample, but I'd be right (and rightly) pissed at anyone that decided that all those other programs were written wrong, and decided to use killall anyway. On a Mac system, this is simply NOT the right way to do this. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Quitting all active applications
I had always naively assumed that all the some *Framework underneath an app was setting up signal handlers for you with default behaviours. If this isn't the case, then yes any killall approach will cause loss of data. Now I'm interested into finding out why this isn't the case. Clark Cox wrote: GUI applications do not generally handle SIGTERM (or any other signals for that matter). Killing GUI applications is a Bad Thing™ :) Randal is correct, this will lose your saved data in any currently open applications. On Thu, Aug 28, 2008 at 10:39 AM, Martin Stoufer [EMAIL PROTECTED] wrote: Actually no, since the default kill signal is TERM, apps will be allowed to prompt to save if necessary. This assumes the app is handling that signal properly. We could send KILL or ABRT and that would just end the processes w/o any save options. Randall Meadows wrote: On Aug 28, 2008, at 10:46 AM, Martin Stoufer wrote: A small app that utilized an NSTask object whose system command would be 'killall -u your short username here -m regex'. And that would be a great way to lose data, if any of the applications getting killed had unsaved documents. -- * Martin C. Stoufer * * ISS/IT * * Lawrence Berkeley National Lab * * 510-486-5306 * * MS 937-700 * ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/clarkcox3%40gmail.com This email sent to [EMAIL PROTECTED] -- * Martin C. Stoufer * * ISS/IT * * Lawrence Berkeley National Lab * * 510-486-5306 * * MS 937-700 * smime.p7s Description: S/MIME Cryptographic Signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Quitting all active applications
On Thu, Aug 28, 2008 at 9:37 AM, Phil Faber [EMAIL PROTECTED] wrote: All I'm trying to achieve is a tiny app that only quits open apps and then quits itself; the purpose being when I want to release as much memory and disc space as possible before I run another memory / processor intensive app. I could just quit each one individually but I guess I'm lazy! No need for a compiled application. You should be able to write this in a small AppleScript that you can just double click. Just ask the list of apps to quit. -Shawn ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Quitting all active applications
On Thu, Aug 28, 2008 at 12:37 PM, Phil Faber [EMAIL PROTECTED] wrote: All I'm trying to achieve is a tiny app that only quits open apps and then quits itself; the purpose being when I want to release as much memory and disc space as possible before I run another memory / processor intensive app. Not much point in that, IMHO - the virtual memory system will usually swap out inactive apps to make room when the active app needs more physical RAM. And if an app is in the background just waiting for user input, it's taking a tiny amount of CPU anyway. sherm-- -- Cocoa programming in Perl: http://camelbones.sourceforge.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Quitting all active applications
On Aug 28, 2008, at 4:53 PM, Sherm Pendley wrote: On Thu, Aug 28, 2008 at 12:37 PM, Phil Faber [EMAIL PROTECTED] wrote: All I'm trying to achieve is a tiny app that only quits open apps and then quits itself; the purpose being when I want to release as much memory and disc space as possible before I run another memory / processor intensive app. Not much point in that, IMHO - the virtual memory system will usually swap out inactive apps to make room when the active app needs more physical RAM. And if an app is in the background just waiting for user input, it's taking a tiny amount of CPU anyway. In fact, telling all applications to quit forces the OS to page in significant chunks of those apps so they can actually execute the quit request. That causes a bunch of VM churn and will hurt performance in the immediate term. Cheers, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]