As title says I have created a on-demand launch agent that listens to socket and is launched on incoming connection. It works well and after it has done it's job I want to quit it. After quitting system automatically restarts it, OS probably thinks it died accidentally. How can I stop this behaviour? My launch agent is a Cocoa application (without GUI), I have tried quitting with 'exit(EXIT_SUCCESS)' and '[[NSApplication sharedApplication] terminate:self]'

My launchd plist is below:

<?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">
    <string>/Library/Application Support/com.mycompany.myproduct/myproduct.app/Contents/MacOS/myproduct</string>


It probably won't help, but you could try sleeping for a few seconds before exiting. From Daemons and Services Programming Guide:

Important: If your daemon shuts down too quickly after being launched, launchd may think it has crashed. Daemons that continue this behavior may be suspended and not launched again when future requests arrive. To avoid this behavior, do not shut down for at least 10 seconds after launch.

You must log in to answer this question.

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