• 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
Re: pid vs. Process Serial Number
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pid vs. Process Serial Number


  • Subject: Re: pid vs. Process Serial Number
  • From: Chris Suter <email@hidden>
  • Date: Thu, 21 Sep 2006 22:07:03 +1000

Can't you use a parameter that gets passed in when run from cron?

On 21/09/2006, at 9:34 PM, Brad Peterson wrote:

Hi all,

I'm trying to determine if my app was launched by cron
so that I can automate certain actions which would
otherwise require interaction.

So, I figured I'd use getppid(), convert the result to
a psn, use that to get the process' name, and then
check for "cron".

But, I always get a -600 when calling
GetProcessForPID().

Has anyone used this successfully? Alternatively, can
anyone suggest a different approach which might work
better?

Thanks!  (Code below)

B

Calling code:

	pid_t pid = getppid();
	NSString *strAppName = pidToProcessName(pid);

my conversion method:

NSString *pidToProcessName(pid_t pid){
    OSErr err;
    NSString *processName;
	NSString  *result = [NSString string];
	ProcessSerialNumber psn;
    psn.highLongOfPSN = 0;
    psn.lowLongOfPSN = 0;
	err = GetProcessForPID(pid, &psn);
	if (err == noErr) {
        //Get name as CFString, which is bridged to
NSString
        CopyProcessName(&psn, (CFStringRef
*)&processName);
        [processName autorelease];
		result = [NSString stringWithString: processName];
		NSLog(result);
    }
    return result;
}

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
systems.com


This email sent to email@hidden


--
Coriolis Systems Limited is a limited company incorporated in England and Wales
Company No. 5061807 Registered Office: 72 New Bond Street, London W1S 1RR




Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: pid vs. Process Serial Number
      • From: Brad Peterson <email@hidden>
References: 
 >pid vs. Process Serial Number (From: Brad Peterson <email@hidden>)

  • Prev by Date: pid vs. Process Serial Number
  • Next by Date: Re: pid vs. Process Serial Number
  • Previous by thread: pid vs. Process Serial Number
  • Next by thread: Re: pid vs. Process Serial Number
  • Index(es):
    • Date
    • Thread