Hi Erwin,
At 10:53 PM +0100 3/17/13, Erwin Namal wrote:
What you want to read is:
man launchd.plist
Best,
-Steve
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (Darwin-dev(a)lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.ap…
This email sent to site_archiver(a)lists.apple.com
The daemon will just maintain a database shared by all users of the
computer, as well as hold some configuration options tied to
external hardware and dialog with kexts. When no user is logged in,
the daemon will be able to answer the kexts questions about the
hardware's configuration. When one or many users are logged in, the
daemon will allow them to access the database in a thread-secure way
as well as modify the hardware config.
Based on this, your deamon is just vending a service and probably
doesn't need to be running all the time, although launchd will give
your clients the illusion that it.
I'm not sure if you can access a daemon from a kext -- you may have
to vend that from a kext (or the IORegistry) and re-vend that from
your daemon of have your daemon connect to your own lext that handles
the kernel side.
What you're going to to do is write a .plist file that declares what
ports (IP or Mach) that your daemon listens on plus a bunch of other
configuration stuff.
based on the contents of you .plist, launchd will register those
ports on your behalf.
The first time that someone tries to connect to that port, launchd
will block the client and launch you (on demand) as part of your
startup, you check in with launchd, it hands you the file
descriptor(s) for the already open port(s), you respond to the
request, and you're on your way.
So, when my daemon is launched, I expose my control sockets and
exit? launchd will keep my daemon resident?
The other way around -- you declare your sockets in your .plist, and
launchd launches you when needed.
I've glossed over a lot for simplicity (for instance Mack and IP
ports aren't the only means of access), but hopefully this will give
you a staring point.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (Darwin-dev(a)lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.ap…
This email sent to site_archiver(a)lists.apple.com
On 18/03/2013, at 7:59 AM, Erwin Namal wrote:
> Hello,
>
> I have a large experience in developing cocoa applications, but none with launchd daemons. I would like to develop a system daemon running from start to shutdown and I know, from the documentation below [1] that there are a few requirements.
> I have tried to compile the sampleD daemon, but it is way outdated and I can't make it work… despite setting it to 64bits and mountain lion.
> So I have a few questions:
>
> 1. Which language can I use for my daemon? Obj-C? C? C++?
> 2. Is there a specific template to use? I saw an XPC service template in Xcode but that's all.
> 3. I know I need to handle SIGTERM, but I don't know how. Are there any other requirements?
> 4. I think that once launched, the daemon must have an infinite loop, right? ShouldI put a sleep() call inside? If yes, for how long?
>
> These are pretty basic questions. I will gladly take any help, any sample code or any link towards documentations… in short amything is good to help me start.
launchd doesn't care what language you use, or how you structure you daemon. For the most part, ignore launchd and write your deamon how you would normally. The one difference you for a launchd daemon vs a normal daemon that you should care about, is the way it handles sockets. That is, launchd itself handles the basic socket code (if your daemon uses sockets).
So, to answer your specific questions:
1. Any.
2. No.
3. Not really, you can (and should) have launchd handle the listening sockets (if any)
More info here:
http://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPS…
4. Polling is typically not what you want (sleep implies polling), you want to listen for events and react when they occur. One nice thing with launchd is you can have a daemon that reacts to socket events, and the daemon itself can actually stop running and be fired up by launchd when a socket event occurs.
Have a read through the documentation, it has most of the information you need
Hope this helps,
Nick
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (Darwin-dev(a)lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.ap…
This email sent to site_archiver(a)lists.apple.com
Hello,
I have a large experience in developing cocoa applications, but none with launchd daemons. I would like to develop a system daemon running from start to shutdown and I know, from the documentation below [1] that there are a few requirements.
I have tried to compile the sampleD daemon, but it is way outdated and I can't make it work… despite setting it to 64bits and mountain lion.
So I have a few questions:
1. Which language can I use for my daemon? Obj-C? C? C++?
2. Is there a specific template to use? I saw an XPC service template in Xcode but that's all.
3. I know I need to handle SIGTERM, but I don't know how. Are there any other requirements?
4. I think that once launched, the daemon must have an infinite loop, right? ShouldI put a sleep() call inside? If yes, for how long?
These are pretty basic questions. I will gladly take any help, any sample code or any link towards documentations… in short amything is good to help me start.
Thanks,
Erwin
[1] https://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BP…
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (Darwin-dev(a)lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.ap…
This email sent to site_archiver(a)lists.apple.com
Le 14 mars 2013 à 13:37, Nat! <nat(a)mulle-kybernetik.com> a écrit :
> Hi
>
> I wanted to compile dyld. But there is a file missing named coreSymbolicationDyldSupport.hpp. If I don't find a file in the package I usually try the xnu package (and google :) but nothing shows up.
>
> dyld.cpp has an #if around the #include
>
> #if CORESYMBOLICATION_SUPPORT
> #include "coreSymbolicationDyldSupport.hpp"
> #endif
>
> but ImageLoader.h turns it on pretty much unconditionally:
>
> #if __IPHONE_OS_VERSION_MIN_REQUIRED
> #define CORESYMBOLICATION_SUPPORT 1
> #else
> #define CORESYMBOLICATION_SUPPORT (__i386__ || __x86_64__)
> #endif
>
> Or should I use ppc ? :D
>
> Ciao
> Nat!
AFAIK, this is an internal header used by the CoreSymbolication private framework to install dyld hooks to get notifications about image loading/unloading.
You can try to define CORESYMBOLICATION_SUPPORT to 0 to compile dyld without it.
-- Jean-Daniel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (Darwin-dev(a)lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.ap…
This email sent to site_archiver(a)lists.apple.com