LSBackgroundOnly App launches, then quits if other user at console
LSBackgroundOnly App launches, then quits if other user at console
- Subject: LSBackgroundOnly App launches, then quits if other user at console
- From: Jerry Krinock <email@hidden>
- Date: Thu, 09 Jun 2005 16:58:11 -0700
My app is launched daily by ".../MyApp.app/Contents/MacOS/MyApp" in my
user's crontab. I want it to always launch as a background app, examine one
of my user's files, do some work, overwrite the file, and then sometimes
come forward with a window showing the results if anything interesting was
done. But if the user is not at the console, I want it to quit, instead of
coming forward.
I set LSBackgroundOnly = "1" in the Info.plist, and I can tell if "my user"
is logged in by comparing the string returned by NSUserName() with that
returned by SCDynamicStoreCopyConsoleUser(,,,). To come foreward, I use
TransformProcessType(,kProcessTransformToForegroundApplication). All this
works fine if my user is logged in, and it also works fine if the Login
Window is showing (because the console user is "loginwindow").
But if a different user is logged in, I have found that main() runs OK up
until NSApplicationMain(), but my application controller's -awakeFromNib
never runs and neither does -applicationDidFinishLaunching; it seems to quit
on NSApplicationMain(), before I get a chance to do anything. Sometimes I
get this error message in the system log:
kCGErrorRangeCheck : Window Server communications from outside of session
allowed for root and console user only
But, I say, I am LSBackgroundOnly and have not asked for any windows to be
"served". Or have I? I only called NSApplicationMain().
I'd very much appreciate some troubleshooting or "where to look"
suggestions. Admittedly, not many of my users will expect my app to work
when they're not logged in but, HEY this is a unix system! At least I want
to understand why it doesn't.
I have tried setting LSUIElement along with, and instead of,
LSBackgroundOnly, but it stil quits just the same. This problem occurs with
10.4.1; I have not tested 10.2 or 10.3 yet.
Jerry Krinock
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden