I have a launchdaemon that is successfully loaded post installation of an app. I want the launchdaemon to load the launchagent in the user context. How can this be achieved on 10.10? Is the following way accurate and approved by Apple.
sudo launchctl bsexec "$PID" sudo -u "$USER" launchctl load /Library/LaunchAgents/pathto.plist
Concerns:
- Is the above way Apple approved? I hope it doesn't get break with OS upgrades?
- Also for confirmation, how can launchdaemon get the values of the PID and USER. Would running the following command from the launchdaemon in root context fetch the accurate logged in user: /usr/bin/who | /usr/bin/awk '/console/{print $1;exit}'
Any help will be appreciable.