Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jun 19, 2013, 09:08 AM   #1
mehdies
macrumors member
 
Join Date: Jun 2012
-6 Status number in "launchctl list"

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?

Last edited by mehdies; Jun 19, 2013 at 09:28 AM.
mehdies is offline   0 Reply With Quote
Old Jun 19, 2013, 09:35 AM   #2
subsonix
macrumors 68040
 
Join Date: Feb 2008
Quote:
Originally Posted by mehdies View Post
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)
subsonix is offline   1 Reply With Quote
Old Jun 19, 2013, 10:26 AM   #3
mehdies
Thread Starter
macrumors member
 
Join Date: Jun 2012
Quote:
Originally Posted by subsonix View Post
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.
mehdies is offline   0 Reply With Quote
Old Jun 19, 2013, 10:33 AM   #4
subsonix
macrumors 68040
 
Join Date: Feb 2008
Quote:
Originally Posted by mehdies View Post
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:

Quote:
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 is offline   1 Reply With Quote
Old Jun 19, 2013, 03:14 PM   #5
subsonix
macrumors 68040
 
Join Date: Feb 2008
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.
subsonix is offline   1 Reply With Quote
Old Jun 19, 2013, 03:40 PM   #6
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by mehdies View Post
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.
chown33 is offline   1 Reply With Quote
Old Jun 22, 2013, 02:36 AM   #7
mehdies
Thread Starter
macrumors member
 
Join Date: Jun 2012
Quote:
Originally Posted by subsonix View Post
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.
Quote:
Originally Posted by chown33 View Post
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 is offline   0 Reply With Quote
Old Jun 22, 2013, 06:56 AM   #8
mehdies
Thread Starter
macrumors member
 
Join Date: Jun 2012
Solved

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


Thanks all
mehdies is offline   0 Reply With Quote
Old Jun 23, 2013, 09:29 AM   #9
mehdies
Thread Starter
macrumors member
 
Join Date: Jun 2012
Sorry but new problem

Quote:
Originally Posted by mehdies View Post
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 :

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 is offline   0 Reply With Quote
Old Jun 26, 2013, 04:41 AM   #10
mehdies
Thread Starter
macrumors member
 
Join Date: Jun 2012
Quote:
Originally Posted by mehdies View Post
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
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?
mehdies is offline   0 Reply With Quote
Old Jun 26, 2013, 05:42 AM   #11
Meir David
macrumors newbie
 
Join Date: Jun 2013
hi

what would happen when it produces a negative signal.
Meir David is offline   0 Reply With Quote
Old Jun 26, 2013, 06:10 AM   #12
mehdies
Thread Starter
macrumors member
 
Join Date: Jun 2012
Quote:
Originally Posted by Meir David View Post
hi

what would happen when it produces a negative signal.
nothing! daemon send error log to console and not work.
mehdies is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Lag with Applications folder (Dock) "view as list" in 15" Retina Macbook Pro Cardsnk MacBook Pro 2 Jun 12, 2014 12:52 AM
select data to use in "Choose From List" list in applescript ShuddaRunThat Mac Programming 2 Apr 1, 2014 07:31 PM
iPhone 5s order status, "T-Mobile Unlocked" removed ronaldcastillo iPhone 4 Sep 25, 2013 05:33 AM
"Early iphone Discount" upgrade status on AT&T eye.surgeon iPhone 2 Sep 11, 2013 07:58 PM
iPhone: [3GS | 6.0.1 | 05.16.07] "unable to load network list" // "no service" Moritz1 Jailbreaks and iOS Hacks 11 Jan 22, 2013 11:36 AM

Forum Jump

All times are GMT -5. The time now is 08:58 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC