2

I am looking to install a privileged helper tool using SMJobBless.
My plist only contains the MachServices key and RunAtLoad key. The RunAtLoad is set to true as I want to be launched automatically after install.

Now, the problem is that once the helper tool is installed and launched and it completes its job successfully - it gets relaunched and this keeps happening again and again.

Original launchd Job Ticket

<?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">  
<key>Label</key>  
<string>com.ak.SMJobBlessHelper</string>  
<key>MachServices</key>  
<dict>  
<key>com.ak.SMJobBlessHelper.mach</key>  
<true/>  
</dict>  
<key>ProgramArguments</key>  
<array>  
<string>/Library/PrivilegedHelperTools/com.ak.SMJobBlessHelper</string>  
</array>  
<key>RunAtLoad</key>  
<true/>  
</plist>

I have tried various things to stop it from launching again but in vain:

  1. Tried to add KeepAlive to false in the plist.
  2. Tried to add KeepAlive as a dictionary with the key SuccessfulExit to false.
  3. Tried to make my app sleep for occult times before quitting like sleeping for 5 minutes, 10 minutes etc. but it still gets launched again.

I have basically run out of ideas, I want it to launch only when I ask and not automatically and that too again and again.

Please help. Thank you very much.


OS: Mac OS X 10.8.4 12E55
Xcode: 4.6.2 (4H1003)

  • Can you please include the plist in the question? – nohillside Oct 21 '13 at 7:18
  • @patrix I have added it. – dDarkLORD Oct 21 '13 at 9:04
1

The launchd job ticket in the question is malformed; the root object must be a dict:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
   ...
</dict>
</plist>

Assuming this is a copy and paste error, how quickly does your com.ak.SMJobBlessHelper complete?

Some launchd configurations require the process remain running for a minimum of 30 seconds – else launchd will consider the process as crashed and automatically relaunch it.

Does your com.ak.SMJobBlessHelper conform to the requirements set out in the launchd documentation?

  • Thanks for replying. Yes, its copy and paste error. The dict is present in the actual plist. My binary completes after about 60 seconds. I have also tried by putting sleep for 5,10 minutes so that launchd does not think we have crashed but in vain. – dDarkLORD Mar 27 '14 at 7:36
  • I have also tried using a simple binary which just sleeps for 30 seconds and returns 0 or 1 but I got the same result and the binary was launched again and again. – dDarkLORD Mar 27 '14 at 7:38
  • I believe it conforms to the requirements in the launchd documentation. – dDarkLORD Mar 27 '14 at 7:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .