Launchd and terminal process launch - is there any difference from that process' viewpoint?
Launchd and terminal process launch - is there any difference from that process' viewpoint?
- Subject: Launchd and terminal process launch - is there any difference from that process' viewpoint?
- From: eveningnick eveningnick <email@hidden>
- Date: Mon, 8 Nov 2010 21:10:33 +0200
what is the difference between a process that was started by launchd and the
same process, started via terminal (without sudo command) in Mac OS 10.5?
Does the first one has some restrictions when it calls Accessibility
functions?
Here is the Preface to my problem. (i apologize that it is a little
complicated and long but i didnt know which parts of the story are
insignificant)
I have three applications: A terminal application written in C (let's call
it a Launch Agent), a cocoa application (let's call it PlugIn) and some
third party GUI app (Master Application).
This Launch Agent, being launched, watches for all other process being
launched, and when it detects that third party Master Application has been
started, it launches PlugIn app.
This Launch Agent is supposed to be started everytime, when the system
starts. That is why i have created a launchd plist file, and i can
start/stop this agent using launchctl command. But of course, I still can
start Launch Agent by opening Terminal, changing directory to the folder
where is located and just typing its binarie's filename instead.
Thus, there are two way to start PlugIn Application:
1) LaunchD starts Launch Agent, which starts PlugIN when Master App is
started
2) a user from terminal starts Launch Agent, which starts PlugIN when Master
App is started
The PlugIn app installs "accessibility application state observers" into now
launched Master Application, using AXObserverAddNotification(myObserver,
thirdAppElement, kAXApplicationDeactivatedNotification, NULL); (actually, it
installs kAXApplicationDeactivatedNotification,
kAXApplicationActivatedNotification, kAXApplicationShownNotification,
kAXApplicationHiddenNotification).
Now the problem i am faced to:
In Mac OS 10.6 it all works great and i get error code 0 (NoError) after
calling AXObserverAddNotification, and my callbacks are called when the
status of Master Application changes (like activated/deactivated). No
matter, by whom the PlugIn app had been started - by started from a Terminal
manually Launch Agent, or by Launch Agent started using launchctl.
In Mac OS 10.5 i get a problem: the application still works flawlessly if i
Launch Agent is started from a Terminal, but the function
AXObserverAddNotification constantly returns kAXErrorCannotComplete. The
Master Application is already launched, it has displayed all its windows,
but i still can't register a callback. (interesting fact that i still can
successfully install EventTaps into that Master application though).
What can cause such a behaviour? The only sane explanation for me is
that in Leopard the process, started by launchd and by a user (via
terminal) -- and therefore the processes (like, my PlugIN), spawned by such
a process, do not have equal privileges to call accessiblity functions. What
could i do to deal with this problem?
If what i described isn't clear enough, i can write a "model" of this
situation - two simple applications - to show "on a real example".
Thanks for any answer!
George
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden