On Nov 16, 2007 11:52 AM, Jeremy Huddleston < email@hidden> wrote: I am hearing this alot, and I think I'm going to take a stab at
writing a new X11.app to combine/replace /u/X/X11.app and /A/U/X11.app
which takes into account many concerns I've been hearing. Please feel
free to add your comments to http://www.x.org/XDarwin_TODO
But, just so you know how we ended up with this ugly solution: The main constraint is that in order for the launch support to work, launchd must be the process that invokes X11 / Xquartz / whatever. That is the only way it can make this call (in Xtrans.c): if (LAUNCH_DATA_ERRNO == launch_data_get_type(checkin_response)) {
fprintf(stderr,"Check-in failed: %s\n",strerror(launch_data_get_errno(checkin_response)));
goto not_launchd;
} (That is where the "Check-in failed: Permission denied" error comes from.)
The next logical solution was to add a "--launched_by_launchd" option, and then modify the launchd plist to pass that on the command line when X11 is invoked by launchd. Then, if X11 was run *without* that option, it could just poke launchd (either by opening the socket, or explicitly using launchctl to start up X11, etc), then exit. Launchd would then launch X11, and everything would be happy.
When I tried that, instead of getting two X11.app icons in my dock, I got none. Why? My best guess is that there's a race there.
Here is the idealized, intended order of events:
1. I double-click /Applications/Utilities/X11.app in Finder 2. Finder tells LaunchServices to execute X11.app 3. LaunchServices tells the Dock to display the X11.app icon 4. X11.app tells launchd to run /Applications/Utilities/X11.app --launched_by_launchd 5. The first X11.app exits. 6. The Dock notices that X11.app has died, and removes the Dock icon. 7. Launchd starts /Applications/Utilities/X11.app --launched_by_launchd 8. LaunchServices tells the Dock to display the X11.app icon 9. ? 10. Profit!
Even this is suboptimal, because you can see the icon disappear in 6 and run again in 8, but such is life.
Instead, what seems to happen is this: 1. I double-click /Applications/Utilities/X11.app in Finder 2. Finder tells LaunchServices to execute X11.app 3. LaunchServices tells the Dock to display the X11.app icon 4. X11.app tells launchd to run /Applications/Utilities/X11.app --launched_by_launchd 7. Launchd starts /Applications/Utilities/X11.app --launched_by_launchd 8. LaunchServices tells the Dock to display the X11.app icon 5. The first X11.app exits. 6. The Dock notices that X11.app has died, and removes the Dock icon.
The dock can tell that the notifications for both #3 and #8 are for the same file, so it suppresses the duplicate notification, and then after #6, we're left with no icon.
I was not aware of the fact that Tiger's Xquartz could display an icon in the Dock without being run by X11.app (for use with XDMCP) -- I'm still not quite sure how it did that, but that might be the best option. launchd could then directly run Xquartz. -- Ben Byer CoreOS / BSD Technology Group, XDarwin maintainer
|