Difference between revisions of "Watchdog"

From AwkwardTV
Jump to: navigation, search
Line 8: Line 8:
 
Yet another failed attempt:
 
Yet another failed attempt:
  
Auto restart is for automatically rebooting after a power failure and is present on a G5 :(
+
Auto restart is for automatically rebooting after a power failure and is present also on Mac.
<pre> pmset autorestart 0
+
You can turni it off using: <tt>pmset autorestart 0</tt><br>
pmset -g
+
As you can see with <tt>pmset -g</tt>:
 
+
<pre>
System-wide power settings:
+
System-wide power settings:
  SleepDisabled          1
+
SleepDisabled          1
Active Profiles:
+
Active Profiles:
  AC Power                -1*
+
AC Power                -1*
Currently in use:
+
Currently in use:
disksleep      0  
+
disksleep      0  
hibernatemode  0
+
hibernatemode  0
displaysleep  0
+
displaysleep  0
powerbutton    0
+
powerbutton    0
sleep          0
+
sleep          0
'''autorestart    0'''
+
autorestart    0
hibernatefile  /var/vm/sleepimage
+
hibernatefile  /var/vm/sleepimage
</pre>
+
</pre>
  
 
Apparently BackRow.framework tells Watchdog that "we are up and running":
 
Apparently BackRow.framework tells Watchdog that "we are up and running":
Line 31: Line 31:
 
  BRSettingsHelper tellWatchdogWeAreUpAndRunning
 
  BRSettingsHelper tellWatchdogWeAreUpAndRunning
  
Here is the code needed to call BackRow functions. Note you must add the BackRow framework to your project.<br><br>
+
Here is the code needed to call BackRow functions. Note you must add the BackRow framework to your project.
 
<pre>
 
<pre>
 
//BRSettingsHelper.h
 
//BRSettingsHelper.h

Revision as of 19:58, 24 March 2007

What is Watchdog

Watchdog reboots the Apple TV it if the GUI isn't running. There's a kext called AppleTCOWatchdog.kext in the /System/Library/Extensions/ folder.

How to disable Watchdog

Yet another failed attempt:

Auto restart is for automatically rebooting after a power failure and is present also on Mac. You can turni it off using: pmset autorestart 0
As you can see with pmset -g:

System-wide power settings:
SleepDisabled          1
Active Profiles:
AC Power                -1*
Currently in use:
 disksleep      0 
 hibernatemode  0
 displaysleep   0
 powerbutton    0
 sleep          0
 autorestart    0
 hibernatefile  /var/vm/sleepimage

Apparently BackRow.framework tells Watchdog that "we are up and running":

strings /System/Library/PrivateFrameworks/BackRow.framework/Versions/A/BackRow
(...)
BRSettingsHelper tellWatchdogWeAreUpAndRunning

Here is the code needed to call BackRow functions. Note you must add the BackRow framework to your project.

//BRSettingsHelper.h
#import <Cocoa/Cocoa.h>


@interface BRSettingsHelper : NSObject {

}

- (void) tellWatchdogWeAreUpAndRunning;  //This function seems to reset the boot count but does not prevent the machine from rebooting.
- (void) reboot;

@end

And now to test it:

#import <Cocoa/Cocoa.h>
#include "BRSettingsHelper.h"

int main(int argc, char *argv[])
{
    BRSettingsHelper * test = [[BRSettingsHelper alloc] init];

        [test reboot]; 
    
   
    return NSApplicationMain(argc,  (const char **) argv);
    
}

Note that to get this to work, the app had to be run as root.
There is also the key:
_kRUIAutoRestartIntervalKey

which is probably used in one of:

-[RUIPreferences boolForKey:]
-[RUIPreferences boolForKey:withValueForMissingPrefs:]
-[RUIPreferences canSetPreferencesForKey:]
-[RUIPreferences descriptionForKey:]
-[RUIPreferences floatForKey:]
-[RUIPreferences integerForKey:]
-[RUIPreferences objectForKey:]
-[RUIPreferences setBool:forKey:]
-[RUIPreferences setFloat:forKey:]
-[RUIPreferences setInteger:forKey:]
-[RUIPreferences setObject:forKey:]
-[RUIPreferences stringForKey:]

This seems to indicate that the auto reboot interval is stored as a key somewhere. I don't know if this is simply used for the Finder.app or if there is something else on the system that will use this.

SettingsHelper has a reference to /sbin/shutdown -r now

Symlinking /sbin/shutdown to /usr/bin/true makes the shutdown command do nothing.

Background information

This Apple document about Watchdog may shed some light:

http://docs.info.apple.com/article.html?artnum=106588&coll=cp (However, on the Apple TV, there is no /etc/watchdog.conf, other than what this document is saying)

Watchdog is not used in Mac OS X 10.4: look at launchd. This is referring to a software watchdog and is probably unrelated to the rebooting problem.