• 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
Re: Using DO from daemon
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using DO from daemon


  • Subject: Re: Using DO from daemon
  • From: Ryan McGann <email@hidden>
  • Date: Fri, 23 May 2003 15:15:52 -0700

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.

  • Prev by Date: Bring an application to the front
  • Next by Date: Re: using a parser generator with a cococa app
  • Previous by thread: Re: Using DO from daemon
  • Next by thread: Re: Using DO from daemon
  • Index(es):
    • Date
    • Thread