site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Hello all, I have a question about the launchd API from launch.h... background: _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com On Oct 3, 2008, at 10:17 AM, Jason Coco wrote: I have a daemon application that is using launchd but is a cross- platform application so I can't make it totally launchd aware (it's written in Java). It has a plist that lives in /Library/ LaunchDaemons and starts up properly without any issues. My problem is that I have created a preference pane that I want the console use to be able to use to get status, set some configuration options and start/stop the service. Your preference pane should talk to the application via IPC (in your case, probably a Unix domain socket). You can specify the socket path in your daemon's property list and get a file descriptor to the socket when you check in with launchd. I don't know much about Java, but I believe you can call C libraries from it. If that's not feasible, create a C wrapper that grabs the file descriptor sets a flag somewhere in the process' environment and then exec(2)s your Java application. Then your Java app can look at its environment and find where the previous occupant of the address space stashed the descriptor. The pref pane includes a setuid helper application that does proper authorization, etc. Your privileged operations should be done in your daemon. We heavily discourage the use of setuid tools, and we're actively trying to cleanse the system of them. however, I can't seem to find my job through the launchd API in order to perform operaitons on it (start/stop, list status, etc). You should do this over an IPC channel. Set your job's KeepAlive to false and send a command over the socket telling it to exit if the user wishes. The next time you write data to the socket, the job will respawn on-demand. -- Damien Sorresso BSD Engineering Apple Inc. smime.p7s