Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I have installed dnsmasq and now I want to be able to start it with launchctl. The problem is that every time I start the app launchctl starts an anonyous process instead of using the specified label.

10247   -   0x100107c30.anonymous.dnsmasq
-       0   com.example.dnsmasq

But I want it to be

10247    0  com.example.dnsmasq

The problem with the anonymous process is that I can't stop it with launchctl. When I run

launchctl stop com.example.dnsmasq

the anonymous process still stays alive.

Here is my property file:

<?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>
    <key>Label</key>
    <string>com.example.dnsmasq</string>    
    <key>ProgramArguments</key>
    <array>
      <string>/usr/local/sbin/dnsmasq</string>
        <string>-p</string>
        <string>2155</string>
        <string>-R</string>
        <string>-A</string>
        <string>/.dev/127.0.0.1</string>
        <string>-x</string>
        <string>/usr/local/var/run/dnsmasq.pid</string>
    </array>
  <key>RunAtLoad</key>
  <false/>
  <key>KeepAlive</key>
  <false/>
</dict>
</plist>

Any idea on how to fix this?

share|improve this question
    
This very question has been asked on Stack Overflow: link. Please avoid cross-posting. –  Bavarious May 7 '11 at 23:04
    
sorry, was just about to delete it on SO. thaught this site would be a better place for this kind of quenstions. –  Mato May 7 '11 at 23:09

1 Answer 1

up vote 5 down vote accepted

That isn't actually launchctl creating a new process; it's most likely dnsmasq itself. If it fork()s into the background, launchd can't tell; then when it talks to launchd, launchd creates an anonymous entry for it. Make sure dnsmasq doesn't background itself.

(The - listed for the regular launchctl list output indicates that the original dnsmasq process exited.)

share|improve this answer
    
Specifically, adding "-k" (or "--keep-in-foreground") to the ProgramArguments array should do it. After doing this, you might also want to switch KeepAlive to true (so launchd will restart it if it quits for some reason). –  Gordon Davisson May 8 '11 at 1:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.