-6 Status number in "launchctl list"

Discussion in 'Mac Programming' started by mehdies, Jun 19, 2013.

  1. mehdies, Jun 19, 2013
    Last edited: Jun 19, 2013

    macrumors member

    Joined:
    Jun 10, 2012
    #1
    I have an application with 2 class in 2 files and 2 method in classes!

    I use NSRunloop and NSTimer to create a daemon.I add one of the methods to nsrunloop(this method call second method in another class).

    i create a plist file for loading and startuping daemon.

    Code:
    <?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">
    <dict>
    	<key>Disabled</key>
    	<false/>
    	<key>Label</key>
    	<string>com.daemon.user</string>
    	<key>OnDemand</key>
    	<false/>
    	<key>ProgramArguments</key>
    	<array>
    		<string>/Library/Application Support/daemon.app/Contents/MacOS/daemon</string>
    	</array>
    	<key>UserName</key>
    	<string>root</string>
    </dict>
    </plist>
    when i loading daemon work good.but when i logout and login or reboot the Mac OS X, daemon not work and status of daemon is -6.

    Code:
    launchctl list | grep com.daemon
    -	-6	com.daemon.user
    what's wrong?
     
  2. macrumors 68040

    Joined:
    Feb 2, 2008
    #2
    If the status is negative it represents the negative of the signal that killed the job. See the man page.

    The signal that match your number according to the kill man page is:

    6 ABRT (abort)
     
  3. thread starter macrumors member

    Joined:
    Jun 10, 2012
    #3
    What this happen? I want my Daemon work forever! i want the daemon stop only when system is reboot.and after reboot again startup.
     
  4. macrumors 68040

    Joined:
    Feb 2, 2008
    #4
    I don't know I did not write the daemon, but if you look at the man page of launchctl you see this:

     
  5. macrumors 68040

    Joined:
    Feb 2, 2008
    #5
    I missed one thing in your plist. What version of OS X are you using? The OnDemand key has been deprecated in 10.5 and replaced with KeepAlive. So if you are using 10.5 or a more recent version, change it.
     
  6. macrumors 603

    Joined:
    Aug 9, 2009
    #6
    Read about the RunAtLoad key for launchd plists.
     
  7. thread starter macrumors member

    Joined:
    Jun 10, 2012
    #7
    I use both of them together.but face with same problem.
    * After logout and login when i unload the daemon and load again works properly!
    Any idea?
     
  8. thread starter macrumors member

    Joined:
    Jun 10, 2012
    #8
    Solved

    in source code i used stringByAppendingString when i logout and login again value of appending string is null.so application aborted!


    Thanks all
     
  9. thread starter macrumors member

    Joined:
    Jun 10, 2012
    #9
    Sorry but new problem

    I use this code snippet in application source code :

    Code:
    NSDictionary *activeApp = [[NSWorkspace sharedWorkspace] activeApplication];
                appName = (NSString*)[activeApp objectForKey:@"NSApplicationName"];
    i use this code for getting active(focused application's) name.application works good but when i logout and login again appName variable got null value!

    * this code snippet exist in a method.i add method to nsrunloop.
    * .plist file exist in first post
     
  10. thread starter macrumors member

    Joined:
    Jun 10, 2012
    #10
    I find out when restart the daemon,it's works well! first i unload the daemon and load again with blow commands :

    Code:
    launchctl unload /Library/LaunchDaemons/daemon.plist
    
    Code:
    launchctl load /Library/LaunchDaemons/daemon.plist
    I have another daemon(second daemon) like mentioned daemon when first daemon got null second daemon restart first daemon.but not works!

    i use mentioned commands in second daemon like below :

    Code:
     system("launchctl unload /Library/LaunchDaemons/daemon.plist");
    
    Code:
      system("/bin/launchctl load /Library/LaunchDaemons/daemon.plist");
    
    but these commands can't restart daemon.when i remove load command unload command works.

    any solution?
     
  11. macrumors newbie

    Joined:
    Jun 13, 2013
    #11
    hi

    what would happen when it produces a negative signal.
     
  12. thread starter macrumors member

    Joined:
    Jun 10, 2012
    #12
    nothing! daemon send error log to console and not work.
     

Share This Page