• 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
[Q] Detecting running processes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Q] Detecting running processes


  • Subject: [Q] Detecting running processes
  • From: Mark de Jong <email@hidden>
  • Date: Mon, 3 Jun 2002 15:10:14 -0700

Hi!

I have a routine that I run to see if an app is running (below). (It's part of a class that deals with "classic" app, hence its name).

The weirdness I'm running into is that if an app is running before I run this app, then I'll see the app in the list of processes. If I then quit the app and re-launch it (without quitting this app), then that app will not show up in the list of processes in this app.

To clarify, we have an app with the below routine (CheckRunning.app) and I have a classic app called "MyClassicApp".

1. I launch MyClassicApp.

2. Then I launch CheckRunning.app
isClassicAppRunning: returns YES

3. Then I quit MyClassicApp
isClassicAppRunning: returns NO

4. Then I launch MyClassicApp
isClassicAppRunning: returns NO

Some details:

- MyClassicApp is a faceless classic app controlled by AppleEvents
- CheckRunning.app is a cocoa app that sends AppleEvents to MyClassicApp
- CheckRunning.app also receives special "I started" and "I died" AE from MyClassicApp

Any suggestions you can offer would be much appreciated. Thanks!

-- Mark


+ (BOOL)isClassicAppRunning:(NSString *)HFSCreator psn:(ProcessSerialNumber *)returnPSN
{
OSType creatorType = NSHFSTypeCodeFromFileType( HFSCreator );
ProcessSerialNumber psn;
Str255 processName;
FSSpec processAppSpec;
ProcessInfoRec pInfo;
BOOL isSame = NO;
BOOL foundRequestedProcess = NO;

pInfo.processName = (StringPtr) &processName;
pInfo.processAppSpec = &processAppSpec;

GetCurrentProcess( &psn );
do {
GetNextProcess( returnPSN );
SameProcess( &psn, returnPSN, &isSame );
if( !isSame ) {
GetProcessInformation( returnPSN, &pInfo );
foundRequestedProcess = ( pInfo.processSignature == creatorType );
}
} while( !isSame && !foundRequestedProcess );

return foundRequestedProcess;
}
_______________________________________________
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: Color comparison
  • Next by Date: InsertText on non editable NSTextView
  • Previous by thread: Re: Color comparison
  • Next by thread: Re: [Q] Detecting running processes
  • Index(es):
    • Date
    • Thread