Re: pid vs. Process Serial Number
Re: pid vs. Process Serial Number
- Subject: Re: pid vs. Process Serial Number
- From: Tommy Nordgren <email@hidden>
- Date: Thu, 21 Sep 2006 21:27:47 +0200
On 21 sep 2006, at 13.34, 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
I don't think BSD subsystem apps have Process Serial Numbers.
Try getting the parent process ID and check it against a pipe connected
to the ps command line app.
This will work, and will be reasonably efficient, since the check
only needs
to be done at startup.
Another option is to ASSUME you are being called from cron,
and set up your GUI in the first Apple Event received
-------------------------------------
This sig is dedicated to the advancement of Nuclear Power
Tommy Nordgren
email@hidden
_______________________________________________
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