<div dir="ltr"><br><br>The asterisk example wouldn&#39;t work here because it depends on the executable supporting being run as a different user.<div>The <font face="monospace, monospace">-U</font> option.<br><br>Thank you anyway Ken.</div><div><br><br><br><br>Although  the mongo example using sudo launches an additional process, it works because <font face="monospace, monospace">daemondo</font> and in turn <font face="monospace, monospace">launchd</font> monitors the whole thing, i.e., </div><div> &quot;<font face="monospace, monospace">sudo -u ${user}  ${prefix}/bin/executable</font>&quot;</div><div><br>instead of monitoring<br> &quot;<font face="monospace, monospace">su</font> <font face="monospace, monospace">-c</font>&quot; only. </div><div>Where the call to &quot;<font face="monospace, monospace">executable</font>&quot; gets lost. In other words, with <font face="monospace, monospace">su</font>, <font face="monospace, monospace">launchd</font> and <font face="monospace, monospace">daemondo</font> automatically restart the su process but not the &quot;<font face="monospace, monospace">executable</font>&quot; .<br><br></div><div>So, I&#39;ll go with his approach. <br><br>Thank you Rainer.<br><br><br><br><br><br>In the future I will use <span style="font-size:12.8px">macports-dev for </span> Portfile writing related discussion as noted in</div><div><a href="https://lists.macosforge.org/mailman/listinfo/macports-dev">https://lists.macosforge.org/mailman/listinfo/macports-dev</a></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><i>Discussion for MacPorts development and Portfile writing. </i></div></div></blockquote><div><div><br></div></div><div><br></div><div><br></div><div><br></div><div>Best<br><br></div><span></span></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Sep 18, 2016 at 10:16 PM, Rainer Müller <span dir="ltr">&lt;<a href="mailto:raimue@macports.org" target="_blank">raimue@macports.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 2016-09-17 17:12, Javier Alcázar wrote:<br>
&gt; I&#39;m creating a new Portfile with startupitem.executable, and wondering<br>
&gt; what is the best way to execute the command with a specific user.<br>
<br>
</span>Just for the future, Portfile development is usually discussed on<br>
macports-dev, where you would reach more developers. The discussion on<br>
macports-users is about usage of the port command and problems with<br>
installs and upgrades.<br>
<span class=""><br>
&gt; I tried using &quot;su -c executable args&quot; but with this approach<br>
&gt; launchd ends up monitoring the &quot;su&quot; process instead of the &quot;executable&quot;<br>
&gt;<br>
&gt; What would you recommend to do so launchd looks at the &quot;executable&quot; process?<br>
<br>
</span>A few ports use this approach, citing from the mongodb port:<br>
<br>
  startupitem.executable  sudo -u ${mongouser} ${prefix}/bin/mongod ...<br>
<br>
While this adds an additional processes to the hierarchy, I do not see<br>
any problem with that. The su/sudo keeps running until the command exits<br>
and any signals sent to su/sudo will be relayed to the executed process.<br>
<span class="HOEnZb"><font color="#888888"><br>
Rainer<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><span style="font-size:12.8px">Javier</span><br></div></div>
</div>