launchd disobeying plist
I am using launchd to execute a shell script whenever any of a set of directories is modified and also when a filesystem is mounted.
The script should not run when it is loaded. It should also run only once whenever a condition for its running is satisfied.
According to my reading of the the man page for launchd.plist, I should be able to make this work with a plist that contains only Label, Program, QueueDirectories, and StartOnMount parameters.
However, in fact the script gets executed when I load the /Library/LaunchAgents directory, and it continues to do this even if I insert a false-valued RunAtLoad key into the plist. So launchd appears to be disobeying the default value of RunAtLoad and also an explicit false value of that key.
Also, once it runs the script is respawned continuously. And this happens even if I add a false-valued KeepAlive key into the plist. So launchd appears to be disobeying the default value of KeepAlive and also an explicit false value of that key.
Moreover, if I specify the script's pathname as the value of a Program key, I get an "Exec format error" message. To make the script run, I need to specify it as the only value of a ProgramArguments key. By my reading these should be equivalent. So launchd appears to be disobeying the value of a Program key.
When the script runs, it runs correctly, and, if launchd is queried about it while it is being respawned, launchd reports that its last exit status was 0.
Here is a plist that seems to at least function, though it runs on load when it should not. I'd like to know why launchd is behaving in all these ways that seem to contradict the man page.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>RunAtLoad</key>
<false/>
<key>ProgramArguments</key>
<array>
<string>/Users/Shared/Library/panlex/org.panlex.syncd.txt</string>
</array>
<key>LaunchOnlyOnce</key>
<true/>
<key>ThrottleInterval</key>
<integer>36000</integer>
<key>KeepAlive</key>
<false/>
<key>QueueDirectories</key>
<array>
<string>/Topics/panlex/panlex-dics/panlex-dics-data/panlex-dics-data-todo/queued</string>
<string>/Topics/panlex/panlex-dics/panlex-dics-data/used</string>
</array>
<key>StartOnMount</key>
<true/>
<key>Label</key>
<string>org.panlex.syncd.txt</string>
</dict>
</plist>
Mac Pro, Mac OS X (10.5.7), iPhone 8GB, Airport Extreme