PDA

View Full Version : -6 Status number in "launchctl list"




mehdies
Jun 19, 2013, 08:08 AM
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.

<?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.

launchctl list | grep com.daemon
- -6 com.daemon.user

what's wrong?



subsonix
Jun 19, 2013, 08:35 AM
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.


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)

mehdies
Jun 19, 2013, 09:26 AM
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)

What this happen? I want my Daemon work forever! i want the daemon stop only when system is reboot.and after reboot again startup.

subsonix
Jun 19, 2013, 09:33 AM
What this happen? I want my Daemon work forever! i want the daemon stop only when system is reboot.and after reboot again startup.

I don't know I did not write the daemon, but if you look at the man page of launchctl you see this:


The second column displays the last exit status of the job. If the number in this column is negative, it represents the negative of the signal which killed the job. Thus, "-15" would indicate that the job was terminated with SIGTERM. The third column is the job's label.

subsonix
Jun 19, 2013, 02:14 PM
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.

chown33
Jun 19, 2013, 02:40 PM
I want my Daemon work forever! i want the daemon stop only when system is reboot.and after reboot again startup.

Read about the RunAtLoad key for launchd plists.

mehdies
Jun 22, 2013, 01:36 AM
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.

Read about the RunAtLoad key for launchd plists.

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?

mehdies
Jun 22, 2013, 05:56 AM
in source code i used stringByAppendingString when i logout and login again value of appending string is null.so application aborted!


Thanks all

mehdies
Jun 23, 2013, 08:29 AM
in source code i used stringByAppendingString when i logout and login again value of appending string is null.so application aborted!

I use this code snippet in application source 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

mehdies
Jun 26, 2013, 03:41 AM
I use this code snippet in application source 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

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

launchctl unload /Library/LaunchDaemons/daemon.plist

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 :

system("launchctl unload /Library/LaunchDaemons/daemon.plist");

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?

Meir David
Jun 26, 2013, 04:42 AM
hi

what would happen when it produces a negative signal.

mehdies
Jun 26, 2013, 05:10 AM
hi

what would happen when it produces a negative signal.

nothing! daemon send error log to console and not work.