Re: pid vs. Process Serial Number
Re: pid vs. Process Serial Number
- Subject: Re: pid vs. Process Serial Number
- From: Spencer Salazar <email@hidden>
- Date: Thu, 21 Sep 2006 11:36:46 -0400
yep, after the name (same as on the command line). cron runs
everything after the schedule specification and before the next
newline as a single command. see man 5 crontab for more details.
spencer
On Sep 21, 2006, at 11:22 AM, Brad Peterson wrote:
Hi,
I didn't realize that was possible.
The code that constructs the cron entry currently
looks like this:
[[NSString stringWithFormat:@"# name: %@\n0@ \"%@\"
&> /dev/null\n",name,schedule,mstr]
Where would I add the parameters? After name?
Thanks!
--- Chris Suter <email@hidden> wrote:
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
__________________________________________________
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:
40gmail.com
This email sent to 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