<html><head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
</head><body bgcolor="#FFFFFF" text="#000000"><br>
<span>
</span><br>
<blockquote style="border: 0px none;"
cite="mid:915DC9C3-D635-40D5-9F85-E534E236416A@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 22, 2015 at
6:19 PM</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"><div
class="">James,</div><div class=""><br class=""></div><div class="">Some
replies inline...</div><div class=""><br class=""></div>On 22 Jul,
2015, at 17:46, 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="">
<meta class="" http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<div class="" text="#000000" bgcolor="#FFFFFF">Damien,<br class="">
<br class="">
Thanks for the suggestion, and apologies for the tardy reply; I just got
buried under twenty other to-do items that were higher on the list.<br
class="">
<br class="">
I tried removing the LimitLoadToSessionType entry from my agent's plist,
but it doesn't make any difference. When trying to install it as a
system-wide agent, the process still doesn't start.<br class=""></div></div></blockquote><div><br
class=""></div><div>In launchd's lexicon, "system-wide agent" is a
conflict of terminology. System-wide things are, by definition, daemons.
Agents are things which run on a per-user basis (cf. launchd(8)). So
the real question is about the desired lifecycle of your job. Do you
want it to run when a user logs in and to go away when the user logs
out? Or do you want it to be available regardless of any user being
logged in?</div></div></div>
</blockquote>
That's the problem; I don't know what to call them. It's an agent, but
it's an agent for all users (/Library/LaunchAgents) to distinguish it
for exclusively for an individual user (~/Library/LaunchAgents). And it
should run in the context of the user's bootstrap, not just within the
GUI login.<br class="">
<blockquote style="border: 0px none;"
cite="mid:915DC9C3-D635-40D5-9F85-E534E236416A@apple.com" type="cite">
<div style="color: rgb(136, 136, 136); margin-left: 24px;
margin-right: 24px;" __pbrmquotes="true" class="__pbConvBody">
<div><blockquote class="" type="cite"><div class=""><div class=""
text="#000000" bgcolor="#FFFFFF">
My reading of LimitLoadToSessionType would lead me to believe that it's
applicable to my service, which *is* an agent. It runs as a regular
user, and the docs would indicate that this property is just a hint to
the load balancer on how to constrain its use of CPU/memory/IO. It
doesn't make sense that it would keep the process from starting in the
first place.<br class=""></div></div></blockquote><div><br class=""></div><div>Wow,
no that's not at all what that key is for. Please file a bug explaining
how the documentation misled you into that impression so we can make it
clearer!</div></div>
</div>
</blockquote>
I think I got this confused with ProcessType. Both have a "Background"
type.<br>
<br>
I'll file a bug report on the docs, but one problem that I run into is
that terms are often never defined. For example, the
LimitLoadToSessionType section in man 5 launchd.plist describes it
thusly:<br>
<br>
"LimitLoadToSessionType <string or array or strings><br>
This configuration file only applies to sessions of the type(s)
specified."<br>
<br>
But the descriptions of what "type(s)" can be is never defined or
explained in the man pages for launchd.plist, launchctl, or launchd. I'm
sure the description of what LimitLoadToSessionType does is accurate,
but I still left wondering what values are valid or what they mean. :)<br>
<blockquote style="border: 0px none;"
cite="mid:915DC9C3-D635-40D5-9F85-E534E236416A@apple.com" type="cite">
<div style="color: rgb(136, 136, 136); margin-left: 24px;
margin-right: 24px;" __pbrmquotes="true" class="__pbConvBody">
<div><div><br class=""></div><div>Session types are basically
collections of certain kinds of jobs. The "Aqua" session is all the jobs
associated with a graphical login on the console. By default, if your
job is an agent, it is loaded into the Aqua session. (That is, if no
LimitLoadToSessionType key is present.)</div><div><br class=""></div><div>The
Background session is a collection of jobs that can run on behalf of a
user even if that user is not logged in at the graphical console. They
might be doing things like performing Spotlight indexing on that user's
home directory even when that user isn't logged in for example.</div></div>
</div>
</blockquote>
What I want, and I think that's what I've configured in the .plist, is a
per-user Agent running in the Background session, for all users. The
.plist is placed in /Library/LaunchAgents and the LimitLoadToSessionType
is set to Background. (See my earlier message. It has all the details.)<br>
<blockquote style="border: 0px none;"
cite="mid:915DC9C3-D635-40D5-9F85-E534E236416A@apple.com" type="cite">
<div style="color: rgb(136, 136, 136); margin-left: 24px;
margin-right: 24px;" __pbrmquotes="true" class="__pbConvBody">
<div><div><br class=""></div><div>So if you have a vanilla Terminal
prompt and do a `launchctl load`, your plist will attempt to load in the
Aqua session. If that service has LimitLoadToSessionType set to
"Background", then that load will fail because it's attempting to load
in the Aqua session and your service has expressed that it should only
load in the Background session.</div></div>
</div>
</blockquote>
In my case, the 'launchctl load ...' command is being executed via
NSTask launched from a helper running as root, itself launched from a
privileged helper service installed via SMJobBless. I don't know if this
puts launchctl in the context of Background session of the user or in
the root System session.<br>
<br>
James<br>
<br>
<br>
</body></html>