The asterisk example wouldn't work here because it depends on the executable supporting being run as a different user. The -U option.
Thank you anyway Ken. Although the mongo example using sudo launches an additional process, it works because daemondo and in turn launchd monitors the whole thing, i.e., "sudo -u ${user} ${prefix}/bin/executable" instead of monitoring "su -c" only. Where the call to "executable" gets lost. In other words, with su, launchd and daemondo automatically restart the su process but not the "executable" . So, I'll go with his approach. Thank you Rainer. In the future I will use macports-dev for Portfile writing related discussion as noted in https://lists.macosforge.org/mailman/listinfo/macports-dev *Discussion for MacPorts development and Portfile writing. * Best On Sun, Sep 18, 2016 at 10:16 PM, Rainer Müller <rai...@macports.org> wrote: > On 2016-09-17 17:12, Javier Alcázar wrote: > > I'm creating a new Portfile with startupitem.executable, and wondering > > what is the best way to execute the command with a specific user. > > Just for the future, Portfile development is usually discussed on > macports-dev, where you would reach more developers. The discussion on > macports-users is about usage of the port command and problems with > installs and upgrades. > > > I tried using "su -c executable args" but with this approach > > launchd ends up monitoring the "su" process instead of the "executable" > > > > What would you recommend to do so launchd looks at the "executable" > process? > > A few ports use this approach, citing from the mongodb port: > > startupitem.executable sudo -u ${mongouser} ${prefix}/bin/mongod ... > > While this adds an additional processes to the hierarchy, I do not see > any problem with that. The su/sudo keeps running until the command exits > and any signals sent to su/sudo will be relayed to the executed process. > > Rainer > -- Javier
_______________________________________________ macports-users mailing list macports-users@lists.macosforge.org https://lists.macosforge.org/mailman/listinfo/macports-users