Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OSX: "Window Server: failed setting the front application to My App"

I am launching a launchAgent from a post install script using the following command:

su -l $LOGGED_IN_USER -c "/bin/launchctl load /Library/LaunchAgents/com.myApp.mac.agent.plist"

The agent displays a status item (NSStatusItem) with a couple of menu options. One of them has a settings option. Clicking this will open an NSWindow, with few NSTextFields. At times, though this window is the top most, whatever I type goes to the underlying app. I am unable to type anything into the text field. Whenever this happens, I notice the following log in the console:

WindowServer[97]: [cps/setfront] Failed setting the front application to MyApp, psn 0x0-0xb20b2, securitySessionID=0x186c5, err=-600

This is not a consistent behaviour. Any idea why this log comes? And is there any work around for this? Is it ok to launch the agent using su -l?

like image 638
Shanti K Avatar asked Nov 10 '22 08:11

Shanti K


1 Answers

I don't know exactly why you're getting that error and behavior. I recommend reading Technical Note TN2083: Daemons and Agents. It explains in detail the various facets of the execution context of a process and how that affects what a process can do. That includes whether or not a process can connect to the Window Server.

For what it's worth, error -600 is procNotFound, whose description is "no eligible process with specified descriptor". It seems that the Window Server is not able to find a process with the given process serial number (PSN) in the given security session.

I would not use -l in your sudo command. A user's login scripts can do all sorts of crazy things and you don't those done by your installer. However, I don't believe that's related to the main problem.

like image 118
Ken Thomases Avatar answered Nov 15 '22 06:11

Ken Thomases