Re: starting daemons in the startup context
Re: starting daemons in the startup context
- Subject: Re: starting daemons in the startup context
- From: Eli Bach <email@hidden>
- Date: Fri, 27 Mar 2009 12:44:05 -0700
On Mar 27, 2009, at 12:24 PM, Bill Janssen wrote:
I'm writing a user-level daemon that periodically, in response to RPC
calls, runs other apps. By user-level, I mean that it runs as a
particular user, typically not an admin user. I need to be able to
let the user restart the daemon, too.
I'm running into problems with this setup, typically because the apps
run by the daemon start crashing after six hours or so of operation,
typically like this:
FAILED TO GET ASN FROM CORESERVICES so aborting.
I also see gethostbyname() failures, etc., presumably because the app
can't connect to lookupd.
I think this is all because the daemon is running in a 'login'
bootstrap
context, instead of the 'startup' bootstrap context, and this
context has
somehow 'decayed'. For instance, when I run
% sudo launchctl bslist 7942
bootstrap_info(): 268435459
%
which is a very odd result.
I see that in
http://developer.apple.com/DOCUMENTATION/DARWIN/Conceptual/KernelProgramming/contexts/contexts.html
,
there's a paragraph saying,
``There are a number of ways to force a program to start in the
startup
context without rebooting or using ssh. However, these are not robust
solutions, and are not recommended. A standard API for starting
daemons
is under consideration. When an official API becomes available, this
chapter will be updated to discuss it.''
Presumably the standard API doesn't exist yet, or that page would have
been updated. So what are some of the 'number of ways'? Preferably
something that doesn't require the user to be an admin or sudoer.
Bill
Bill,
First, if you can require 10.5, have you looked at launchagents (which
only launch when a user logs in, and run as the logged in user vs
launchdaemons, which launch typically at startup, and aren't linked to
logged in users). It's my understanding that these execute in the
user's context, and not the bootstrap context.
For 10.4 support, there is 'loginhook'...
I haven't specific experience with it, but if they are run as the
logged in user, the user should be able to start/stop it (for
themselves) without having to provide admin authority.
And the web page you mention doesn't seem to have been updated with
info about launchd/launchctl, which should also provide you with
valuable information.
Eli
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden