Re: Using DO from daemon
Re: Using DO from daemon
- Subject: Re: Using DO from daemon
- From: email@hidden
- Date: Fri, 23 May 2003 15:37:02 -0700 (PDT)
From his (the original poster) description though, it seems that both the Server
and Client are startup items, thus should be in the "Startup" namespace right??
so is what you (ryan) are saying is that any objet in the "Startup" namespace
cannot communicate with any other object using DO? that doesn't sound right to
me...
On Fri, 23 May 2003 15:15:52 -0700, Ryan McGann wrote:
>
>
On Thursday, May 22, 2003, at 10:00 PM,
>
email@hidden wrote:
>
>
>>> I've got an command-line app that acts as a client to a distributed
>
>>> objects server. The app can't get the root proxy if it's running as a
>
>>> startup item, but can when run from the command-line.
>
>>>
>
>>> The server vends its proxy with:
>
>>>
>
>>> [self createConnectionName: @"foo"];
>
>>>
>
>>> - (NSConnection*) createConnectionName:(NSString*)name
>
>>> {
>
>>> NSConnection* newConnection=[[NSConnection alloc] init];
>
>>> if ([newConnection registerName:name])
>
>>> {
>
>>> [newConnection setRootObject:self];
>
>>> }
>
>>> else
>
>>> {
>
>>> [newConnection release];
>
>>> newConnection=nil;
>
>>> }
>
>>> return newConnection;
>
>>> }
>
>>>
>
>>> The client obtains its proxy with:
>
>>> id rootProxy = [NSConnection
>
>>> rootProxyForConnectionWithRegisteredName:@"foo" host: nil];
>
>>>
>
>>> The server is a normal Cocoa application running with user
>
>>> permissions.
>
>>>
>
>>> The client is a command-line background application running as root.
>
>>>
>
>>> If the client is launched from the command-line with:
>
>>> sudo client &
>
>>>
>
>>> it works fine (obtains the proxy and is able to successfully use it).
>
>>>
>
>>> If the client is run from a StartupItem (/Library/StartupItems
>
>>> script)
>
>>> with:
>
>>> client &
>
>>> then rootProxy is nil.
>
>>>
>
>>> In fact, as a check, I've also tried:
>
>>> NSConnection *c = [NSConnection
>
>>> connectionWithRegisteredName:@"foo"
>
>>> host: nil];
>
>>>
>
>>> It too returns nil.
>
>>>
>
>>> This may be related to a posting from October, 2001
>
>>> <http://www.omnigroup.com/mailman/archive/macosx-dev/2001-October/
>
>>> 019728.html> where someone was having a similar problem running an
>
>>> application from crontab (worked fine from the command line, failed
>
>>> when running from crontab). However, there were no replies to the
>
>>> question at that time.
>
The problem has to do with Mac OS X/Darwin namespaces. There have been
>
several people on this list with the same question, with varying
>
different reasons. Basically the problem is that all processes started
>
up before a user is logged in are started up in the "startup"
>
namespace. When a user logs in, another namespace is created by the OS,
>
and all applications launched by that user are launched in that
>
namespace. The problem is that applications in the startup namespace
>
cannot "see" applications in the login namespace (it has to do with the
>
way the Mach bootstrap server works).
>
>
Basically in order to communicate from your client process to the
>
startup item, you can use DO. But to communicate from the startup item
>
to the client, you'll need another form of communication. Any IPC
>
method that uses mach ports (notification center, mach ports,
>
CFMessagePort, etc.) have the same problem; BSD sockets is the only
>
form of communication on Mac OS X that doesn't suffer from this problem.
>
>
Ryan
>
_______________________________________________
>
cocoa-dev mailing list | email@hidden
>
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.