[launchd-dev] fork & exit in Shell Script (Revisited)
DarwinsKernel at gmail.com
Mon Nov 10 10:13:11 PST 2008
On Nov 10, 2008, at 9:35 AM, Quinn wrote:
> At 13:56 -0500 5/11/08, Charles Darwin wrote:
>> What is the proper way of shutting down a daemon? Another daemon
>> that runs a bit later?
> OK, I'm really confused )-:
> Let's start by agreeing on terminology. I'm using the terms from
> TN2083. Please familiarise yourself with them (specifically
> "daemon", "agent" and "background program").
> If your background program is a "daemon" it is, by definition, not
> running on behalf of a specific user.
Then I have got the definition wrong. Since my script doesn't have
any GUI I thought it would be a daemon. But I'm getting the felling
that that is not the right criteria.
Now lets call it and "agent", then according to what we have here:
I should be able to put the plist file into "personal LaunchAgents
directories of specific users". I assume that would be ~/Library/
LaunchAgents (or at least that's what the man page for launchd reads):
> And thus it should not be affected by users logging in and out.
It is affected (taking it to be a daemon) and here is why. Here is
if [ ! -d "/Volumes/tutorial" ] ; then
/bin/mkdir -p /Volumes/tutorials && /sbin/mount_afp afp://
if [ ! -d "/Volumes/home" ] ; then
/bin/mkdir -p /Volumes/homes && /sbin/mount_afp afp://url/
When user logs out OS X ejects the mounted afp volumes (tutorials &
homes in the example above).
Now lets again call it an agent so I can use ~/Library/LaunchAgents
(Per-user agents provided by the user) to launch my script whenever
that particular user logs in. Well it just sits there and does
nothing. The plist is loaded however:
$ launchctl list
Here is the plist by the way:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://
> Furthermore, when you started talking about
> I got even more confused because launchd doesn't load launchd
> daemons from the user's home directory.
True. But as I asked before should it handle agents from ~/Library/
Thanks again for helping me with this Quinn.
> Can you give me a quick overview of the what you want your
> background program to do? I'm specifically interested in the
> context in which the process should run and its expected lifecycle.
> Quinn "The Eskimo!" <http://www.apple.com/
> Apple Developer Relations, Developer Technical Support, Core OS/
> launchd-dev mailing list
> launchd-dev at lists.macosforge.org
More information about the launchd-dev