Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

c5kolb

macrumors newbie
Original poster
Dec 4, 2012
2
0
I am trying to get launchd to start a process and keep it running upon the creation of a file path and to kill that process when the file path is deleted. So far my plist file does cause launchd to create the process but when the file path disappears my process is not killed and continues to run.

Here is plist file:

<?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>Label</key>
<string>com.acme.Aloha</string>
<key>Program</key>
<string>/Library/Aloha/sbin/Aloha.rb</string>
<key>ProgramArguments</key>
<array>
<string>Aloha.rb</string>
<string>--config</string>
<string>/Library/Application Support/Aloha/etc/client.conf</string>
</array>
<key>KeepAlive</key>
<dict>
<key>PathState</key>
<dict>
<key>/dev/tun1</key>
<true/>
</dict>
</dict>
<key>Debug</key>
<true/>​
</dict>
</plist>

The intent to to start the Aloha process when the /dev/tun1 device is created by Tunnelblick, or when a VPN connection is established, and then kill the process when the /dev/tun1 device is deleted, or when the VPN connection is disconnected. The fact that I am using Tunnelblick or a VPN is a detail and should have no bearing on launchd.

The bottom line is that the process gets created as intended but is left to run.

I have determined that /dev/tun1 does get deleted and the Aloha process continues to run. I see nothing in /var/log/system.log from launchd until I manually kill the Aloha process.

What am I missing?

Thanks!

Take care,
Chris
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.