Re: NSDistributedNotification Strangeness..
Re: NSDistributedNotification Strangeness..
- Subject: Re: NSDistributedNotification Strangeness..
- From: Brian Hill <email@hidden>
- Date: Fri, 15 Jun 2001 15:09:24 -0500
On Friday, June 15, 2001, at 10:52 AM, Charles Bennett wrote:
This is pretty wierd so I'll try to explain what I'm observing with
NSDistributedNotification.
Assumptions: Except where noted, everything I'm doing is done as the
root user.
I have a unix daemon that starts at bootup just like Apache.
It starts fine, disconnects from a controlling terminal etc..
the daemon forking code is stright out of "Stevens" and has been used
around here for
years.
<snip>
No matter what type of user I login as, the client will not see any of
the distributed
notifications until the daemon is killed and restarted. Even if I'm
already "root" and
the daemon is owned by and starts as root.
If I'm not logged in as root, I have to "su - root" to "really" be
root and restart the daemon. voila! I start seeing
notifications. Now to make it more strange. If I log out (not
restart, just logout) and log back in as another user.
I have the SAME problem again. No notifications until the daemon is
restarted, though in every case I'm su'ing to root
to do the restart.
Well, apparently, NSDistributedNotificationCenter is working the same
way it did back on OSX Server 1.x.
Here's the rub (and it's a nasty one).
Only processes started by a user logged into the console (ie, the
Workspace Manager, or now the Finder) will send or receive
NSDistibutedNotifications. If a process is started at boot time (like
your daemon, the first time you start it), sending the notification may
as well be to /dev/null -- they don't go anywhere.
The second time you start your daemon, it is being started by a process
that was launched via the console (the shell, and ultimately
Terminal.app).
I'd assume the same was true of the CFNotifications, but haven't tested
it yet on OSX 10.0.x.
I discovered this some years ago after it was a bit too late to switch
gears and decided to go with Omni's OFDistributedNotificationCenter,
which uses a 'notification daemon' and DO to provide the same sort of
interface (except that it works with 'server daemon' apps started at
boot time).
Brian
ps. No, it's not in the documentation anywhere -- at least it didn't
used to be.
email@hidden
http://personalpages.tds.net/~brian_hill
"Why? I came into this game for adventure - go anywhere, travel
light, get in, get out, wherever there's trouble, a man alone.
Now they've got the whole country sectioned off and you can't
move without a form. I'm the last of a breed."
-- Archibald "Harry" Tuttle, Rogue HVAC Repairman