Thanks Damien, Gregory, and Mihai for all the great info.

So, here's what we (I've) learned:

(1) A process running in the "Background" session does not guarantee that the home folder is reachable.

(2) Logging out might make the home folder unreachable.

(3) If the home folder isn't reachable when the user's bootstrap and Background session are created, a background service that loads only in the "Background" session might not start.

Issues (1) and (2) aren't too much of concern for my product (backup software) because it's only really useful when the home folder is reachable. For the vast major of users, the home folder is reachable before and after they log out, so these are edge cased that I'll address as such.

(3) is the big problem. If the service is limited to the "Background" session, and it isn't started when the background session is created, it is never started. This is, essentially, the bug I'm trying to fix.

Question/Idea:

Rereading the LimitLoadToSessionType in man launchd.plist, it occurred to me that this can be an array, and it can be omitted. If I omit it or set it to ["Background","Aqua"], would that solve my problem? I would hope that setting it to an array would mean the service can run in *either* the background or GUI session. This leads me to hope that it would be loaded in the Background session if it could, and then again in the Aqua session if it couldn't. (My fear is that it would start two services, but I can actually deal with that pretty easily.)

Problem/FOOBAR:

All of this speculation about mounting and unmounting home folders has been very instructional, but I just got this cold dose of reality: I've heard back from my customer and they say that there is nothing special about their home folder. It's a SSD iMac with a vanilla installation of El Capitan. Furthermore, this same problem just happened to *me* on my MacPro system (still on Yosemite, 'cause I can't upgrade to Xocde 7 just yet). I can guarantee that my home folder is on my boot partition and I don't employ any FileVault encryption, mountpoints, links, etc. I have my Mac set to automatically log into my primary account on startup. This morning my scheduler agent wasn't running and I found this in my system.log:

Nov 7 09:46:04 marchhare.local otherbsd[382]: Failed to bootstrap agent: path = /Users/james/Library/LaunchAgents/com.qrecall.scheduler.plist, error = 134: Service cannot load in requested session

Also disturbing is that I don't see any evidence that my system daemon installed in /Library/LaunchDaemons/com.qrecall.scheduler.kickstart.plist is ever started, either. I'm reconfiguring it's stdout to log to a specific file to confirm this, but so far it doesn't look like it's getting started.

So, I'm back to square #1. Does anyone have any other ideas as to why an installed LimitLoadToSession=Background,RunAtLoad=1 service wouldn't be started by launchd?

I'm adding Debug=1 to my agent and daemon .plist(s) in the hopes that might provide some useful information.

James
_______________________________________________
launchd-dev mailing list
launchd-dev@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/launchd-dev

Reply via email to