Domanda

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.

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)

È stato utile?

Soluzione

Use KeepAlive with PathState key. Create a file when you want to launch your task. Delete that file before returning zero from your helper tool.(Remove RunAtLoad key)

PathState Each key in this dictionary is a file-system path. If the value of the key is true, then the job will be kept alive as long as the path exists. If false, the job will be kept alive in the inverse condition. The intent of this feature is that two or more jobs may create semaphores in the file-system namespace.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top