Stopping Dovecot using launchctl I have Dovecot running as a daemon via a launchd plist. It runs fine but doesn't stop if I run launchctl stop nor if I unload the plist so I end up using doveadm stop. Is there a key or command I add to the plist to tell it how to stop a service? I've checked the man pages for launchd.plist and launchctl but can't find anything like it.

This is the relevant part of the plist:

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
  &lt;dict&gt;
    &lt;key&gt;Label&lt;/key&gt;
    &lt;string&gt;local.dovecot&lt;/string&gt;
&lt;!-- 
    &lt;key&gt;KeepAlive&lt;/key&gt;
    &lt;false/&gt;
 --&gt;
    &lt;key&gt;RunAtLoad&lt;/key&gt;
    &lt;true/&gt;
    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
      &lt;string&gt;/opt/pkg/sbin/dovecot&lt;/string&gt;
&lt;!--       &lt;string&gt;-F&lt;/string&gt; --&gt;
    &lt;/array&gt;
    &lt;key&gt;StandardErrorPath&lt;/key&gt;
    &lt;string&gt;/Library/Logs/Dovecot/stdout.log&lt;/string&gt;
    &lt;key&gt;StandardOutPath&lt;/key&gt;
    &lt;string&gt;/Library/Logs/Dovecot/stderr.log&lt;/string&gt;
  &lt;/dict&gt;
&lt;/plist&gt;


There's no KeepAlive or anything like that, it's a very simple plist.

Any help with this will be much appreciated.
The trouble goes away if I uncomment the -F switch (which I commented while I was trying to get some other part of the set up to work). The -F switch runs Dovecot in the foreground and does not daemonize.

From this answer on SuperUser:


  Launchd expects the programs it launches not to daemonize themselves; if they do, launchd detects it as the program exiting, and cleans up all subprocesses (i.e. kills the now-daemonized program).


In this case it didn't kill the program (as I wouldn't expected if the switch was the wrong one), it just relinquished control so it wouldn't/couldn't shut it down.

Note to self, try the obvious thing, your assumptions may be wrong.