<html><head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
</head><body bgcolor="#FFFFFF" text="#000000">Damian,<br>
<br>
Thanks for sticking with me. OK, here's what I've tried:<br>
<span>
</span><br>
<blockquote style="border: 0px none;"
cite="mid:26EA1761-1F07-404C-B106-388F90DB9C6B@apple.com" type="cite">
<div style="margin:30px 25px 10px 25px;" class="__pbConvHr"><div
style="display:table;width:100%;border-top:1px solid
#EDEEF0;padding-top:5px"> <div
style="display:table-cell;white-space:nowrap;vertical-align:middle;width:100%">
        <a moz-do-not-send="true" href="mailto:dsorresso@apple.com"
style="color:#737F92
!important;padding-right:6px;font-weight:bold;text-decoration:none
!important;">Damien Sorresso</a></div> <div
style="display:table-cell;white-space:nowrap;vertical-align:middle;">
<font color="#9FA2A5"><span style="padding-left:6px">July 23, 2015 at
8:35 AM</span></font></div> </div></div>
<div style="color: rgb(136, 136, 136); margin-left: 24px;
margin-right: 24px;" __pbrmquotes="true" class="__pbConvBody"><meta
content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">On 22
Jul, 2015, at 22:49, James Bucanek <<a moz-do-not-send="true"
class="" href="mailto:subscriber@gloaming.com">subscriber@gloaming.com</a>>
wrote:<div><blockquote class="" type="cite"><div class=""><blockquote
class="" style="font-family: Menlo-Regular; font-size: 12px; font-style:
normal; font-variant: normal; font-weight: normal; letter-spacing:
normal; orphans: auto; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255,
255); border: 0px none;" type="cite"
cite="mid:915DC9C3-D635-40D5-9F85-E534E236416A@apple.com"><div
style="margin: 30px 25px 10px;" class="__pbConvHr"><div class=""
style="display: table; width: 901px; border-top-width: 1px;
border-top-style: solid; border-top-color: rgb(237, 238, 240);
padding-top: 5px;"><div class="" style="display: table-cell;
white-space: nowrap; vertical-align: middle; width: 721px;"><a class=""
style="padding-right: 6px; font-weight: bold; color: rgb(115, 127, 146)
!important; text-decoration: none !important;"
href="mailto:dsorresso@apple.com" moz-do-not-send="true">Damien Sorresso</a></div><div
class="" style="display: table-cell; white-space: nowrap;
vertical-align: middle;"><font class="" color="#9FA2A5"><span class=""
style="padding-left: 6px;">July 22, 2015 at 6:19 PM</span></font></div></div></div></blockquote></div></blockquote></div><br
class=""><div class="">That is your problem. In that context,
`launchctl load` will attempt to load your job as a daemon because it is
running as root in the root Mach bootstrap. One thing that's critical
to understand is that there's nothing about the contents of your plist
which identifies it as a daemon or agent; the same plist can be loaded
into multiple contexts. Each context can have sessions within it. As it
turns out, the only place this matters is the per-user context, which
has Background and Aqua. The intended effect of `launchctl load` and
friends is determined by your calling context.</div></div>
</blockquote>
<br>
I'm getting that.<br>
<blockquote style="border: 0px none;"
cite="mid:26EA1761-1F07-404C-B106-388F90DB9C6B@apple.com" type="cite">
<div style="color: rgb(136, 136, 136); margin-left: 24px;
margin-right: 24px;" __pbrmquotes="true" class="__pbConvBody"><div
class=""><br class=""></div><div class="">This is why the new bootstrap
subcommand introduced in Yosemite takes an explicit parameter
identifying the context you want to bootstrap the job into. Try changing
your NSTask invocation in your helper tool to this:</div><div class=""><br
class=""></div><div class="">launchctl bootstrap user/$UID
/path/to/plist</div></div>
</blockquote>
Here's the experiment I performed. I uninstalled all of my software,
created a test .plist file on my desktop that points to a working
version of my user agent, and issued the following command<br>
<br>
sudo launchctl bootstrap user/501
/Users/james/Desktop/com.qrecall.scheduler.plist<br>
<br>
Here's what worked:<br>
<br>
- The QRecallScheduler executable started up for user 501 (yea!).<br>
<br>
- Using 'launchctrl print user/501' and 'launchctl print
user/501/com.qrecall.scheduler' I can see that the agent was installed.<br>
<br>
Where's what doesn't work:<br>
<br>
The agent only runs for user 501. When I log in with another user, the
agent doesn't start. Now this is consistent with my understanding of the
"user/501" domain; this syntax refers to the session belonging to user
501 and only user 501.<br>
<br>
This is not what I'm trying to accomplish. (I have the per-user stuff
working just fine). I'm trying, as an administrator (root), to install a
user agent that will run FOR ALL USERS.<br>
<br>
This is my frustration with the documentation for the new launchctl. I
can see that "system/" applies to the root system (daemons). I
understand that "user/PID" applies to the context of a single user, as
does its various synonyms (login/ASID, gui/UID, session/ASID, ...). What
I can't figure out is the syntax for addressing a user agent to be
started for ALL users. Said another way, how do you say to launchctl "I,
the administrator, have installed a user agent that needs to be
installed and started for every logged in user, here's its .plist"?
After that command, if there were three users logged in, I'd expect
three instances of my agent to start.<br>
<br>
I tried "user/*". It doesn't work. ;)<br>
<br>
Finally, I notice that 'launchctl bootstrap ...' does not copy the
.plist to the /Library/LaunchAgents or ~/Library/LaunchAgents folder,
and after restarting the system my agent is no longer running and no
longer appears in 'launchctl print user/501'. I infer from this that to
permanently install a user agent, I'm still responsible for copying the
.plist to the appropriate directory (/Library/LaunchAgents or
~/Library/LaunchAgents).<br>
<br>
Having now vented my angst over this whole mess, I'm considering a
solution that bypasses the need to install an agent for all users.<br>
<br>
You've helped me by clearly describing the difference between a
"Background" session for a user and the "Aqua" session for a user. I'm
thinking now that I don't need to install a user agent for all users. I
just need to install a "Background" agent for each users that wants the
scheduler to run when they are logged out, and I can do that without
needing admin authorization. I still need the "kicker" system daemon to
create the session for each user (with a scheduler installed) before
they've logged in, but that should also start all of the per-user
"Background" agents in ~/Library/LaunchAgents for that user, correct?<br>
<br>
James<br>
<br>
</body></html>