• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Terminating an Application ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Terminating an Application ?


  • Subject: Terminating an Application ?
  • From: Alec Carlson <email@hidden>
  • Date: Mon, 04 Nov 2002 16:14:44 -0600

I want to terminate a running application from another application. There
really is no easy way to do this, however, I've come up with the following
code which works.

NSArray * RunningApplications;
NSDictionary * ApplInfo;
NSEnumerator * enumerator;
NSNumber * pid;

RunningApplications = [[NSWorkspace sharedWorkspace] launchedApplications];
enumerator = [RunningApplications objectEnumerator];
while( (ApplInfo = [enumerator nextObject]) )
{
if( (theName = [ApplInfo objectForKey:@"NSApplicationName"]) )
{
if( (pid = [ApplInfo objectForKey:@"NSApplicationProcessIdentifier"]) )
{
NSLog( @"Process %@ has pid:%@", theName, pid );
if( [theName isEqualToString:@"SomeAppName"] == YES )
kill( [pid intValue], SIGTERM );
}
}
}

My question is, are there any hidden problems associated with terminating an
OS X app in this fashion ?

Thanks -

Alec
-----------------------------------------------------------------------
Time is Short and the Water Rises
-----------------------------------------------------------------------
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: end of sheet and re-activationg window
  • Next by Date: Re: Clearing cells in NSBrowser
  • Previous by thread: Re: Writing documentation for the help menu item
  • Next by thread: Re: Terminating an Application ?
  • Index(es):
    • Date
    • Thread