site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:cc:message-id:from:to :in-reply-to:content-type:mime-version:subject:date:references :x-mailer; bh=iHufPcuHl91GjeJ9dYP9+VQQCBNunCsCQXgXfR0Ry2s=; b=Ftn/d6DRyJrEA972syxVD7tRPIlQP8pa6usd9F8CBT5LiUhUCkKSrKqM2LT2gDkSDA Sduud8CyFpxjDnkkWS/g3nKIfv2J1Zc5kFEGG9ZyzcGC529UlxNUyC/vuRM17Mw/a0xJ BOciFat7BgFEERiKQEldK8fhDjRBpgYsWLGKY= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=cc:message-id:from:to:in-reply-to:content-type:mime-version:subject :date:references:x-mailer; b=GQVx7AluQkD//P5VsufgeT65IPnsPJf3gIYwCOBfx39T/kg4JPMtvKGxlGyPVBxpak jF6EFybMmhY78NH9W4gVg+Ls602h4+X/4c3hAj4BGpZOaW/mARxxFKtyAsDycBpeXKgD dIlIVJEswkUO/PiPU8bC7/yRpBPaSqqYbPhVs= On Oct 3, 2008, at 14:02 , Damien Sorresso wrote: Hello all, I have a question about the launchd API from launch.h... background: Thanks again, Jason _______________________________________________ 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. Thanks for the advice, Damien. I'll re-work it to do something like this... although, unfortunately, I can't alter the Java code at this point so I'll have to have the wrapper program manage the without using exec. I will have the wrapper manage everything, as you suggest, and use IPC from the pref pane to do configuration. I do have one more question on how you'd recommend the design of this... since I can't alter the Java source right now, do you think it makes sense to add 2 plists to launchd... one being the wrapper and one being the Java app. Then I could have the Java app depend on the wrapper and have the wrapper instruct launchd to load and unload the app as needed. This way I can check-in with launchd and communicate appropriately. Or... do you think it's better to simply add the wrapper daemon to launchd and then have the wrapper manage a fork/exec of the Java process? 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. I agree... I didn't want to do it that way, but I didn't think of your solution... smime.p7s