Re: weird problem ...
Re: weird problem ...
- Subject: Re: weird problem ...
- From: Lloyd Dupont <email@hidden>
- Date: Fri, 9 May 2003 12:18:51 +1000
mach ports cannot be done except after an exec, not fork.
ha ? uh ...
how could I do then ?
I plan to make it a StartupItem, so I need to make it a daemon, I mean
at last I should return immediately (and how to do that, if not by
using fork() ?)
and then I want to be able to do advanced communication, if I could
avoid having to write my own version of DO on top of socket that would
be cool.. any idea ?
Thanks,
Andrew Pinski
On Thursday, May 8, 2003, at 20:39 US/Eastern, Lloyd Dupont wrote:
I use DO with NSSocketPort & NSSocketPortNameServer.
and that's ok.
however I recently tried to make my application a daemon.
so I initialize with stuff like:
pid_t pid;
if( (pid = fork()) < 0 )
return -1;
else if(pid != 0)
return 0;
setsid();
chdir("/");
umask(0);
and then register to DO with
NSSocketPort *sport = [[[NSSocketPort alloc]
initWithTCPPort:aPort]
autorelease];
// fail on the line below
if([[NSSocketPortNameServer sharedInstance] registerPort:sport
name:aName] == NO)
return FALSE;
NSConnection * connection = [[[NSConnection alloc]
initWithReceivePort:sport sendPort:nil] autorelease];
[connection setRootObject:self];
however, when my program is running as a daemon it always fail to
register to DO with the following error:
"There was an error creating a resolve, (ipc/send) invalid destination
port"
I don't understand ... any idea ?
(and yes, the name and port are available)
_______________________________________________
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.