Terminating an Application ?
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.