[launchd-dev] run once and then vaporize

Quinn eskimo1 at apple.com
Thu Jul 24 07:43:28 PDT 2008


At 19:15 -0700 23/7/08, Blake Garner wrote:
>My test script currently just echo's some text into system.log and
>exits. The script runs but the launchd item fails to unload or remove
>itself.

That's because launchd does not pass the ProgramArguments to a shell; 
rather, it invokes fork/exec (maybe even posix_spawn these days) with 
those arguments.  So the ";" isn't considered special.  If you modify 
your "runonce.sh" to print all of its arguments, you'll find that 
it's getting a whole bunch of extra ones (-:

I don't think this ProgramArguments approach is going to work.  You 
will have to unload the job from your script.

Alternatively, don't unload the job.  Once a job is loaded, it 
doesn't depend on the plist file, so removing the plist file out from 
underneath launchd won't cause you any problems.  The job will 
continue to exist in launchd (until the system restarts) but it won't 
get run against unless someone specifically invokes it.

S+E
-- 
Quinn "The Eskimo!"                    <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware


More information about the launchd-dev mailing list