• 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
How to create Daemon for Mac 10.4
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to create Daemon for Mac 10.4


  • Subject: How to create Daemon for Mac 10.4
  • From: Elango C <email@hidden>
  • Date: Thu, 5 Jan 2006 15:41:39 +0530

Hi Alberto Ricart,

Can you tell me how to create a Daemon,  That is Is this a C/C++ tool
or a standard tool.  I am using Xcode version 2.2, I could not see any
template for the Daemon.

I am new to this concepts, please guide me to fix it up.

Thanks,
--Elango

On 1/4/06, Elango C <email@hidden> wrote:
> Hi Alberto Ricart,
>
> Thanks for the reply and code snippet,  I will try this and let you
> know the queries if any.
>
> Thanks,
> --Elango
>
> On 1/3/06, Alberto Ricart <email@hidden> wrote:
> > Hi Elango,
> >
> > Not during startup. The UI application can only be launched at login
> > because you need a window server connection. If you are a daemon
> > process you don't have access to the window sever, thus no ui from
> > there.
> > The only solution is to break your functionality into two apps. One
> > that is the 'server' and a client (the ui).
> >
> > 1) is the daemon. This could be extremely simple if you use DO:
> >
> > //@todo: might need to handle signals
> > int main(int argc, char *argv[])
> > {
> > 	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
> >
> > 	NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
> >
> > 	NSObject <SomeProtocolYouMake> *server = [[NannySessionProvider
> > alloc]init];
> >
> > 	NSConnection *conn = [NSConnection defaultConnection];
> > 	[conn setRootObject:server];
> > 	if(! [conn registerName:@"com.foo.my.server"])
> > 	{
> > 		NSLog(@"Unable to register server");
> > 	}
> > 	else
> > 	{
> > 		[runLoop run];
> > 	}
> >
> > 	// if we are here the runloop terminated
> > 	[sessionProvider release];
> > 	[pool release];
> >
> > 	return 0;
> > }
> >
> >
> > 2) the other is the client:
> >
> > - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
> > {
> > 	NSString *name = @"com.foo.my.server";
> > 	NSDistantObject *o = [NSConnection
> > rootProxyForConnectionWithRegisteredName:name host:nil];
> >
> > 	if(o == nil)
> > 	{
> > 		//@todo: Ohoh - the daemon is dead... launch it?
> > 		NSLog(@"Unable to connect to the server. Exiting...");
> > 		[NSApp terminate:self];
> > 	}
> >
> > 	[o setProtocolForProxy:@protocol(SessionProvider)];
> > 	id <SessionProvider> sessionProvider = (< SomeProtocolYouMake >)o;
> >
> > 	// call all sorts of methods defined by your protocol...
> >
> >
> >
> > /a
> >
> >
> > On Jan 3, 2006, at 1:21 AM, Elango C wrote:
> >
> > > hi,
> > >
> > > Can I launch the UI application (i.e. Cocoa application) during OS
> > > startup?.. Can you send me a code snippets to create
> > > services/daemon/startup items.
> > >
> > > Thanks,
> > > --Elango
> > >
> > > On 1/3/06, Alberto Ricart <email@hidden> wrote:
> > >> The app that does the backup should have backup privileges - probably
> > >> operator, (because of how it is launched), and should probably be
> > >> started by launchd services/or be daemon/startup item/etc. This means
> > >> that it would already be running as root, and thus not require
> > >> authentication.
> > >>
> > >>
> > >> /a
> > >>
> > >>  _______________________________________________
> > >> 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
> > >>
> >
> >
> >
>
 _______________________________________________
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: How to create Daemon for Mac 10.4
      • From: Alberto Ricart <email@hidden>
    • Re: How to create Daemon for Mac 10.4
      • From: Finlay Dobbie <email@hidden>
  • Prev by Date: Multiple targets, multiple definitions of symbol
  • Next by Date: No windowWillClose: on quit?
  • Previous by thread: Re: Multiple targets, multiple definitions of symbol
  • Next by thread: Re: How to create Daemon for Mac 10.4
  • Index(es):
    • Date
    • Thread