Difference between revisions of "Watchdog"

From AwkwardTV
Jump to: navigation, search
m
m (reverting spammed page)
Line 1: Line 1:
[http://ultra-creator.110mb.com/articles/occhiali-smith.htm occhiali smith slider] [http://blue-olusha.110mb.com/library/sami-yusuf/ sami yusuf mp3] [http://dialed.110mb.com/small/timer-meccanico/ timer meccanico giornaliero] [http://olikka.110mb.com/library/da-vhs.htm da vhs a dvd] [http://book-wench.110mb.com/text/michael-bouble/ michael bouble lyrics] [http://trouble166.110mb.com/videos-xxxxx.htm videos xxxxx] [http://sister-sunshine.110mb.com/html/masterizzatori-dvd/ masterizzatori dvd lacie 16x double] [http://unremig.110mb.com/nek-jon/ nek jon jacobs] [http://yeeden.110mb.com/data/in-ogni/ in ogni atomo] [http://gekijuls.110mb.com/u-atomic/ u2 atomic bomb] [http://sister-sunshine.110mb.com/html/lancia-delta/ lancia delta 16] [http://nationavce.110mb.com/view/nerina-montagnani.htm nerina montagnani] [http://unremig.110mb.com/presentatrice-piazza/ presentatrice piazza grande] [http://gekijuls.110mb.com/film-in/ film in dvd pozzi orlowsky] [http://mouse-zae.110mb.com/jvc-.htm jvc  drmx1s] [http://trene-von-anty.110mb.com/description/yu-gi.htm yu gi oh game pc] [http://funk-mastah-ion.110mb.com/data/touran-highline.htm touran highline] [http://stitchesnglue.110mb.com/dil-dhoonde.htm dil dhoonde] [http://olikka.110mb.com/library/monika-sport.htm monika sport modelle] [http://funk-mastah-ion.110mb.com/data/asus-a.htm asus a620 tastiera] [http://unremig.110mb.com/car-crash/ car crash] [http://some-omeelse.110mb.com/data/sunrise-sunshine.htm sunrise sunshine mp3] [http://mouse-zae.110mb.com/magic-system.htm magic system ft 113 and mohamed lamine] [http://trene-von-anty.110mb.com/description/kenny-g.htm kenny g one more time] [http://yeeden.110mb.com/data/sonic-x/ sonic x vol 01] [http://olikka.110mb.com/library/disegni-ape.htm disegni ape] [http://olikka.110mb.com/library/euro-hotel.htm euro hotel praga] [http://nationavce.110mb.com/view/ninfeta.htm ninfeta] [http://stitchesnglue.110mb.com/earphones.htm earphones] [http://olikka.110mb.com/library/karaoche.htm karaoche] [http://sneezingpops.110mb.com/congelatore-ignis/ congelatore ignis icfs23] [http://yeeden.110mb.com/data/sanmarino/ sanmarino] [http://ultra-creator.110mb.com/articles/school-sex.htm school sex] [http://lazythoughts.110mb.com/lib/www-tim/ www tim it com] [http://ultra-creator.110mb.com/articles/fantasma-opera.htm fantasma opera] [http://some-omeelse.110mb.com/data/gioco-gratis.htm gioco gratis download] [http://forever-your.110mb.com/data/denbighshire.htm denbighshire] [http://ultra-creator.110mb.com/articles/heidi-klum.htm heidi klum tonight show] [http://ultra-creator.110mb.com/articles/london-vintage.htm london vintage guitar shop] [http://sister-sunshine.110mb.com/html/adsl-lazio/ adsl lazio] [http://book-wench.110mb.com/text/il-gioco/ il gioco degli innamorati] [http://olikka.110mb.com/library/pasta-presto.htm pasta presto imperia] [http://dialed.110mb.com/small/subwoofer-kenwood/ subwoofer kenwood] [http://unremig.110mb.com/agriturismo-albano/ agriturismo albano laziale] [http://blue-olusha.110mb.com/library/tania-maria/ tania maria] [http://forever-your.110mb.com/data/subaru-imprezza.htm subaru imprezza usate] [http://nationavce.110mb.com/view/jeep-cherokee.htm jeep cherokee 25 td 3p] [http://dialed.110mb.com/small/videocamere-canon/ videocamere canon mv830] [http://olikka.110mb.com/library/business-advertising.htm business advertising] [http://dialed.110mb.com/small/navigatore-palmone/ navigatore palmone] [http://sneezingpops.110mb.com/vintage-/ vintage 55 felpa uomo] [http://dialed.110mb.com/small/zion-y/ zion y lenox en vivo] [http://book-wench.110mb.com/text/zoom-/ zoom 18125 3 55 6 dc sigma] [http://lazythoughts.110mb.com/lib/cartoline-auguri/ cartoline auguri di pasqua] [http://slavkamolot.110mb.com/library/ferr/ ferr] [http://stitchesnglue.110mb.com/giorgio-serafini.htm giorgio serafini] [http://sneezingpops.110mb.com/crash-nitro/ crash nitro recer] [http://gekijuls.110mb.com/lavoro-modena/ lavoro modena] [http://sneezingpops.110mb.com/il-gioco/ il gioco del cavallo di barbie] [http://gekijuls.110mb.com/street-hunter/ street hunter] [http://gekijuls.110mb.com/gps-ericsson/ gps ericsson] [http://stitchesnglue.110mb.com/www-passalibro.htm www passalibro it] [http://sister-sunshine.110mb.com/html/ufficio-imperia/ ufficio imperia] [http://trene-von-anty.110mb.com/description/non-ci.htm non ci lasceremo] [http://slavkamolot.110mb.com/library/www-giochi/ www giochi 135 it] [http://dialed.110mb.com/small/finanziamento-viareggio/ finanziamento viareggio] [http://lazythoughts.110mb.com/lib/likasi/ likasi] [http://dialed.110mb.com/small/dj-gunther/ dj gunther] [http://dialed.110mb.com/small/noleggio-mini/ noleggio mini cabrio] [http://book-wench.110mb.com/text/se-be/ se be ala ye] [http://gekijuls.110mb.com/scatolificio-in/ scatolificio in campania] [http://funk-mastah-ion.110mb.com/data/volkswagen-golf.htm volkswagen golf comfortline 1 9 tdi] [http://unremig.110mb.com/seggiolini-auto/ seggiolini auto 9  36 kg] [http://book-wench.110mb.com/text/ferri-da/ ferri da stiro a vapore con caldaia] [http://trouble166.110mb.com/temi-svolti.htm temi svolti immigrazione] [http://blue-olusha.110mb.com/library/claude-challe/ claude challe experience] [http://mouse-zae.110mb.com/economico-modelli.htm economico modelli aerei ed elicotteri] [http://gekijuls.110mb.com/radioa-fm/ radioa fm] [http://ultra-creator.110mb.com/articles/teoria-dei.htm teoria dei bioritmi] [http://stitchesnglue.110mb.com/whitney-live.htm whitney live] [http://funk-mastah-ion.110mb.com/data/dissipatori-asus.htm dissipatori asus] [http://sneezingpops.110mb.com/il-nintendo/ il nintendo ds in un concorso italiano] [http://gekijuls.110mb.com/notre-dame/ notre dame deparis] [http://yeeden.110mb.com/data/driverr/ driver3r] [http://olikka.110mb.com/library/lavatrice-lg.htm lavatrice lg 10 kg] [http://forever-your.110mb.com/data/torretta-pari.htm torretta pari] [http://funk-mastah-ion.110mb.com/data/unione-sarda.htm unione sarda] [http://dialed.110mb.com/small/hp/ hp 7210] [http://stitchesnglue.110mb.com/garmin-legend.htm garmin legend color] [http://ultra-creator.110mb.com/articles/mesa-mesa.htm mesa mesa el que aplauda] [http://blue-olusha.110mb.com/library/www-latincards/ www latincards com] [http://funk-mastah-ion.110mb.com/data/solo-ieri.htm solo ieri midi file] [http://unremig.110mb.com/ungherese/ ungherese] [http://slavkamolot.110mb.com/library/gewis/ gewis] [http://trouble166.110mb.com/come-il.htm come il cielo ivana spagna] [http://gekijuls.110mb.com/il-giorno/ il giorno di san valentino] [http://yeeden.110mb.com/data/last-minute/ last minute costa crociere] [http://dialed.110mb.com/small/sony-web/ sony web] [http://funk-mastah-ion.110mb.com/data/la-ragazza.htm la ragazza di parigi] [http://blue-olusha.110mb.com/library/giochi-americani/ giochi americani] [http://olikka.110mb.com/library/faccia-al.htm faccia al muro] [http://blue-olusha.110mb.com/library/emilia-romagna/ emilia romagna vacanze] [http://nationavce.110mb.com/view/dlink-wireless.htm dlink wireless adsl router kit] [http://mouse-zae.110mb.com/video-avril.htm video avril] [http://trene-von-anty.110mb.com/description/ricevitori-accessori.htm ricevitori accessori gps] [http://blue-olusha.110mb.com/library/nat-king/ nat king cole for sentimental reasons] [http://olikka.110mb.com/library/le-auto.htm le auto piu vendute] [http://yeeden.110mb.com/data/verona-it/ verona it] [http://ultra-creator.110mb.com/articles/camera-a.htm camera a bergamo] [http://dialed.110mb.com/small/remix-la/ remix la serenissima] [http://lazythoughts.110mb.com/lib/adattatore-atx/ adattatore atx] [http://ultra-creator.110mb.com/articles/io-grecia.htm io (grecia)] [http://ultra-creator.110mb.com/articles/sparkle-fx.htm sparkle fx 5500] [http://forever-your.110mb.com/data/odys-mps.htm odys mp3s5] [http://gekijuls.110mb.com/sesso-video/ sesso video consigliato] [http://nationavce.110mb.com/view/hpcompaq-palmari.htm hpcompaq palmari] [http://some-omeelse.110mb.com/data/renato-zero.htm renato zero triangolo] [http://funk-mastah-ion.110mb.com/data/cavo-connessione.htm cavo connessione video] [http://funk-mastah-ion.110mb.com/data/tripod.htm tripod] [http://nationavce.110mb.com/view/marcia-aeronautica.htm marcia aeronautica] [http://dialed.110mb.com/small/losing-grip/ losing grip avril lavigne] [http://sister-sunshine.110mb.com/html/shota/ shota] [http://unremig.110mb.com/punto-internet/ punto internet] [http://funk-mastah-ion.110mb.com/data/data-cartridge.htm data cartridge] [http://funk-mastah-ion.110mb.com/data/fernando-poo.htm fernando poo] [http://some-omeelse.110mb.com/data/gerona-provincia.htm gerona (provincia)] [http://unremig.110mb.com/lodivecchio/ lodivecchio] [http://forever-your.110mb.com/data/hard-disk.htm hard disk seagate 100gb] [http://stitchesnglue.110mb.com/asus-mb.htm asus 512mb] [http://slavkamolot.110mb.com/library/email/ email] [http://some-omeelse.110mb.com/data/annuncio-affitto.htm annuncio affitto privato] [http://book-wench.110mb.com/text/zucchero-baboomba/ zucchero baboomba] [http://funk-mastah-ion.110mb.com/data/www-atlantic.htm www atlantic group net] [http://book-wench.110mb.com/text/change-opening/ change opening page] [http://lazythoughts.110mb.com/lib/okelly-michael/ okelly michael] [http://trene-von-anty.110mb.com/description/hd-usb.htm hd usb esterno 2 5] [http://sneezingpops.110mb.com/prestito-siviglia/ prestito siviglia] [http://gekijuls.110mb.com/cyber-shot/ cyber shot sony dscw1] [http://mouse-zae.110mb.com/volo-aereo.htm volo aereo cataniamilano] [http://mouse-zae.110mb.com/mercedes-bergamo.htm mercedes bergamo] [http://unremig.110mb.com/clio-/ clio 14 rti] [http://funk-mastah-ion.110mb.com/data/pizzo-macrame.htm pizzo macrame] [http://gekijuls.110mb.com/scale-ringhiera/ scale ringhiera] [http://trene-von-anty.110mb.com/description/aisha-mp.htm aisha mp3] [http://olikka.110mb.com/library/stereo-yamaha.htm stereo yamaha] [http://dialed.110mb.com/small/foto-erica/ foto erica bella] [http://dialed.110mb.com/small/turkey-trouble/ turkey trouble v01] [http://yeeden.110mb.com/data/was/ was] [http://sister-sunshine.110mb.com/html/yesterdat-yes/ yesterdat yes a day] [http://some-omeelse.110mb.com/data/vegt.htm vegt] [http://slavkamolot.110mb.com/library/la-vendetta/ la vendetta delluomo invisibile] [http://gekijuls.110mb.com/emule-server/ emule server] [http://trouble166.110mb.com/focolarini.htm focolarini] [http://slavkamolot.110mb.com/library/san-bassano/ san bassano] [http://yeeden.110mb.com/data/isdn-card/ isdn card] [http://yeeden.110mb.com/data/encarta-premium/ encarta premium 2006] [http://yeeden.110mb.com/data/televisore/ televisore 15] [http://gekijuls.110mb.com/presario-/ presario 1299 hpcompaq computer] [http://lazythoughts.110mb.com/lib/albatron-geforce/ albatron geforce] [http://yeeden.110mb.com/data/renoir/ renoir 1841 1919] [http://funk-mastah-ion.110mb.com/data/del-pita.htm del pita] [http://book-wench.110mb.com/text/nude-in/ nude in discoteca] [http://yeeden.110mb.com/data/hari/ hari] [http://trene-von-anty.110mb.com/description/www-manutd.htm www manutd com] [http://sister-sunshine.110mb.com/html/on-boy/ on boy] [http://unremig.110mb.com/kodak-easyshare/ kodak easyshare printer dock plus] [http://sister-sunshine.110mb.com/html/parto-indolore/ parto indolore] [http://dialed.110mb.com/small/guru-infradito/ guru infradito] [http://ultra-creator.110mb.com/articles/kuens.htm kuens] [http://ultra-creator.110mb.com/articles/perugia.htm perugia] [http://olikka.110mb.com/library/creedence.htm creedence] [http://lazythoughts.110mb.com/lib/fax-raffaello/ fax raffaello] [http://trene-von-anty.110mb.com/description/enio-morikone.htm enio morikone] [http://nationavce.110mb.com/view/mita-dc.htm mita dc 1560] [http://funk-mastah-ion.110mb.com/data/nike-wmns.htm nike wmns] [http://stitchesnglue.110mb.com/tintoretto-lan.htm tintoretto lan] [http://slavkamolot.110mb.com/library/bravo-murillo/ bravo murillo juan] [http://dialed.110mb.com/small/swedin/ swedin] [http://nationavce.110mb.com/view/benito-mussolini.htm benito mussolini foto] [http://mouse-zae.110mb.com/golino-alfredo.htm golino alfredo] [http://gekijuls.110mb.com/jewellery/ jewellery] [http://yeeden.110mb.com/data/www-uci/ www uci it] [http://blue-olusha.110mb.com/library/www-edunet/ www edunet tn] [http://lazythoughts.110mb.com/lib/salone-auto/ salone auto parigi] [http://funk-mastah-ion.110mb.com/data/schwob-libri.htm schwob libri] [http://trouble166.110mb.com/bonnie-clyde.htm bonnie clyde] [http://book-wench.110mb.com/text/coniglietto-nano/ coniglietto nano] [http://gekijuls.110mb.com/bisex-roma/ bisex roma] [http://dialed.110mb.com/small/paul-marchall/ paul marchall] [http://trene-von-anty.110mb.com/description/eternity-calvin.htm eternity calvin klein donna] [http://olikka.110mb.com/library/reklama-na.htm reklama na ticho] [http://mouse-zae.110mb.com/il-viaggiatore.htm il viaggiatore parigi] [http://trene-von-anty.110mb.com/description/tetone.htm tetone] [http://dialed.110mb.com/small/joss-stone/ joss stone the soul sessions] [http://mouse-zae.110mb.com/reki-music.htm reki music] [http://dialed.110mb.com/small/noleggio-auto/ noleggio auto brescia] [http://dialed.110mb.com/small/volkswagen-polo/ volkswagen polo 14 tdi] [http://stitchesnglue.110mb.com/pietra-serena.htm pietra serena srl] [http://mouse-zae.110mb.com/call-of.htm call of duty la grande offensiva] [http://sister-sunshine.110mb.com/html/hard-disk/ hard disk portatile 2 5 acer] ===What is Watchdog===
+
===What is Watchdog===
  
 
Watchdog is a service monitoring daemon responsible for rebooting the Apple TV if its GUI application is not running. Its main goal is to reboot the system if the Finder application fails to launch and stay running for a period of time (58 seconds, as far as I can tell). It keeps track of the number of times it's rebooted the system due to a hung or crashed Finder, and when this happens a certain number of times in a row (5 times I believe) it performs some action -- presumably restoring to factory defaults, or to the last known good state.
 
Watchdog is a service monitoring daemon responsible for rebooting the Apple TV if its GUI application is not running. Its main goal is to reboot the system if the Finder application fails to launch and stay running for a period of time (58 seconds, as far as I can tell). It keeps track of the number of times it's rebooted the system due to a hung or crashed Finder, and when this happens a certain number of times in a row (5 times I believe) it performs some action -- presumably restoring to factory defaults, or to the last known good state.
Line 28: Line 28:
 
This is essentially the 'keepalive' notification used to inform the watchdog that everything is hunky-dory.
 
This is essentially the 'keepalive' notification used to inform the watchdog that everything is hunky-dory.
  
Upon launch, ripstop switches to the Frontrow user
+
Upon launch, ripstop switches to the Frontrow user & group ID, then opens a COM interface to the watchdog service, and creates a notification port with a CFMachPortRef wrapper which it then runs via a CFRunLoop. In the main function, it makes the following calls into the watchdog service:
 +
(*service)->tcoWdSetTimer( service, 500 );
 +
(*service)->tcoWdLoadTImer( service );
 +
 
 +
These are the actions performed for each notification:
 +
 
 +
com.apple.riptide.heartbeat:
 +
(*service)->tcoWdLoadTimer( service );
 +
 
 +
com.apple.riptide.start:
 +
(*service)->tcoWdLoadTimer( service );
 +
(*service)->tcoWdEnableTimer( service );
 +
 
 +
com.apple.riptide.stop:
 +
(*service)->tcoWdDisableTimer( service );
 +
 
 +
com.apple.ripstop.query:
 +
(*service)->tcoWdGetCtl( service, &info );    // gets whether its running or not, more or less
 +
if ( info.counterIsRunning )
 +
    notify_post( com.apple.tcowd.ison );
 +
else
 +
    notify_post( com.apple.tcowd.isoff );
 +
 
 +
com.apple.ripstop.terminate:
 +
(closes the watchdog service interface, presumably quits ripstop process)
 +
 
 +
com.apple.ripstop.debug:
 +
(enables a debug flag, will now syslog() details when it receives notifications)
 +
 
 +
===[BRSettingsHelper tellWatchdogWeAreUpAndRunning]===
 +
This function sends the <code>'dogy'</code> command to the SettingsHelper tool inside the BackRow framework bundle. It essentially resets the Watchdog's failure counters in NVRAM, since the Watchdog is only interested in failures to launch the interface. Once the interface launches successfully, this function is called and the data is cleared.
 +
 
 +
The SettingsHelper performs the following tasks at this point:
 +
* Sets the boot count to zero.
 +
* Sets the maximum boot count to five.
 +
* Clears the system reset reason.
 +
* Clears the remote state.
 +
 
 +
===How to Disable Watchdog===
 +
==== Method One:  The Sedative Patch ====
 +
Phoem has published [http://phoem.com/TCOWatchDog-sedative.c source code for sedative], a patch for AppleTCOWatchdog application.
 +
==== Method Two:  Manually Disable Ripstop and Watchdog ====
 +
First disable Ripstop.  Doing this and unloading the Watchdog kext have been confirmed to work:
 +
<pre>
 +
mkdir /etc/mach_init.disabled
 +
mv /etc/mach_init.d/ripstop.plist /etc/mach_init.disabled
 +
</pre>
 +
 
 +
Reboot using the following command.
 +
<pre>
 +
shutdown -r now
 +
</pre>
 +
 
 +
Ripstop is now disabled.  To disable Watchdog, unload AppleTCOWatchdog.kext:
 +
<pre>
 +
kextunload -b com.apple.driver.AppleTCOWatchdog
 +
</pre>
 +
 
 +
To unload the AppleTCOWWatchdog.kext automatically at startup. add the command to your local startup script.  This is recommended as it is best to have Ripstop and Watchdog either both enabled or both disabled. In some cases the rc.local file doesn't exist. A way around it is to use su. (su is a rather dangerous command as it effectively allows you to log in as root so use it wisely!)
 +
 
 +
Copy /usr/bin/su from your local OS X installation to the same location on the AppleTV.
 +
 
 +
Then issue these commands
 +
 
 +
<pre>
 +
sudo su -
 +
touch /etc/rc.local
 +
</pre>
 +
 
 +
Then, after you verified that rc.local exists...
 +
 
 +
<pre>
 +
echo "/sbin/kextunload -b com.apple.driver.AppleTCOWatchdog" >> /etc/rc.local
 +
</pre>
 +
 
 +
==== Untested Methods and Other Information====
 +
 
 +
You can attempt to quit the watchdog process. Watchdog is (or at least used to be) "quit" in a special way. Locate the watchdog process and send it a 'SIGTERM' term.
 +
 
 +
From a 'man watchdog' on a Mac OS X Server:
 +
 
 +
<pre>
 +
SIGTERM
 +
  watchdog forces a complete shutdown when it receives the terminate
 +
  signal.  The automatic reboot timer will be disabled and all exe-
 +
  cuting children will be terminated, forcibly (with SIGKILL) if nec-
 +
  essary.  After all children have terminated, watchdog itself exits.
 +
  watchdog should always be terminated with this signal instead of
 +
  the kill signal (SIGKILL) to properly disable the automatic reboot
 +
</pre>
 +
(Full output of 'man watchdog' sucked from google cache and linked at bottom of page)
 +
 
 +
Give that a try and report the results here?
 +
 
 +
 
 +
 
 +
Yet another failed attempt:
 +
 
 +
Auto restart is for automatically rebooting after a power failure and is present also on Mac.
 +
You can turn it off using: <tt>pmset autorestart 0</tt><br>
 +
As you can see with <tt>pmset -g</tt>:
 +
<pre>
 +
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
 +
</pre>
 +
 
 +
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.
 +
<pre>
 +
//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
 +
</pre>
 +
And now to test it:
 +
<pre>
 +
#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);
 +
   
 +
}
 +
</pre>
 +
 
 +
Note that to get this to work, the app had to be run as root.
 +
<br>
 +
There is also the key:<br>
 +
_kRUIAutoRestartIntervalKey<br><br>
 +
which is probably used in one of: <br><br>
 +
 
 +
-[RUIPreferences boolForKey:]<br>
 +
-[RUIPreferences boolForKey:withValueForMissingPrefs:]<br>
 +
-[RUIPreferences canSetPreferencesForKey:]<br>
 +
-[RUIPreferences descriptionForKey:]<br>
 +
-[RUIPreferences floatForKey:]<br>
 +
-[RUIPreferences integerForKey:]<br>
 +
-[RUIPreferences objectForKey:]<br>
 +
-[RUIPreferences setBool:forKey:]<br>
 +
-[RUIPreferences setFloat:forKey:]<br>
 +
-[RUIPreferences setInteger:forKey:]<br>
 +
-[RUIPreferences setObject:forKey:]<br>
 +
-[RUIPreferences stringForKey:]<br><br>
 +
 
 +
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 <tt>/sbin/shutdown -r now</tt>
 +
 
 +
Symlinking <tt>/sbin/shutdown</tt> to <tt>/usr/bin/true</tt> makes the shutdown command do nothing.
 +
 
 +
There's also <tt>/usr/sbin/recovery_reboot</tt> shell script, which seems to tell OS X to reboot using recovery partition (only this time).
 +
Perhaps (pretty doubtful) it is called when watchdog sniffs something bad. Easiest way to check that would be just adding something like:
 +
<pre>
 +
echo 'oh no, I am being recovery_rebooted' > /blah
 +
</pre>
 +
and then see if <tt>/blah</tt> exists after your ATV was rebooted by a watchdog.
 +
 
 +
===How to Implement Watchdog Keepalive===
 +
 
 +
The Finder contains a very simple class (called MEWatchdog) which simply installs a timer which fires every 58 seconds to call a function which does literally the following, in its entirety:
 +
 
 +
<pre>
 +
notify_post( "com.apple.riptide.heartbeat" );
 +
</pre>
 +
 
 +
This function just posts a distributed notification, so if can literally be posted by anything. Unless the Watchdog inspects the interval between notifications, it's likely that any application can perform the same test, along with the Finder, if started by something like launchd. This way, the watchdog would not reboot the machine, even if the Finder quits, and we don't have any potential side-effects arising from stopping a system process.
 +
 
 +
As an aside, 'Riptide' appears to be a codename of sorts for the AppleTV software system. Various elements within BackRow print out debug statements including file/line information, which begin with <tt>/SourceCache/Riptide-xxx/</tt>.
 +
 
 +
===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 [http://developer.apple.com/macosx/launchd.html launchd].  This is referring to a software watchdog and is probably unrelated to the rebooting problem.
 +
 
 +
Link to a Google cache (possibly old) output of 'man watchdog' with possibly useful information in it:
 +
 
 +
http://72.14.253.104/search?q=cache:J8bC2hERg9YJ:www.hmug.org/man/8/watchdog.html+Mac+OS+X+Server+Watchdog&hl=en&ct=clnk&cd=16&gl=us
 +
 
 +
[[Category:Software]][[Category:How-to]]

Revision as of 04:12, 27 August 2007

What is Watchdog

Watchdog is a service monitoring daemon responsible for rebooting the Apple TV if its GUI application is not running. Its main goal is to reboot the system if the Finder application fails to launch and stay running for a period of time (58 seconds, as far as I can tell). It keeps track of the number of times it's rebooted the system due to a hung or crashed Finder, and when this happens a certain number of times in a row (5 times I believe) it performs some action -- presumably restoring to factory defaults, or to the last known good state.

There's a kext called AppleTCOWatchdog.kext in the /System/Library/Extensions/ folder.

Brief Watchdog Background

Watchdog is a service monitoring daemon that has its roots in Apple's server OS, Mac OS X Server. Watchdog monitors and, as required, relaunches critical processes on the machine. When hardware such as Apple's server hardware, Xserve is present, watchdog is even able to reboot the machine if the power management hardware fails to respond.

This should not be confused with the "watchdog" program from OS X 10.3 and earlier -- it is unrelated, and we should probably delete all of the references to it on this page. :/

The Ripstop Daemon

Ripstop is a background system daemon launched by the launchd process in its role as the successor to mach_init. Ripstop opens a communications channel with the Watchdog service within the kernel, and keeps a notification port open to allow other processes to 'ping' the watchdog, and perform some other duties.

Ripstop Details

Ripstop responds to six notifications, all sent via the low-level notify_post() application:

  • com.apple.riptide.heartbeat
  • com.apple.riptide.start
  • com.apple.riptide.stop
  • com.apple.ripstop.query
  • com.apple.ripstop.debug

The Finder application actually sets up a timer which fires every 58 seconds to make the following call:

notify_post( "com.apple.riptide.heartbeat" );

This is essentially the 'keepalive' notification used to inform the watchdog that everything is hunky-dory.

Upon launch, ripstop switches to the Frontrow user & group ID, then opens a COM interface to the watchdog service, and creates a notification port with a CFMachPortRef wrapper which it then runs via a CFRunLoop. In the main function, it makes the following calls into the watchdog service:

(*service)->tcoWdSetTimer( service, 500 );
(*service)->tcoWdLoadTImer( service );

These are the actions performed for each notification:

com.apple.riptide.heartbeat:

(*service)->tcoWdLoadTimer( service );

com.apple.riptide.start:

(*service)->tcoWdLoadTimer( service );
(*service)->tcoWdEnableTimer( service );

com.apple.riptide.stop:

(*service)->tcoWdDisableTimer( service );

com.apple.ripstop.query:

(*service)->tcoWdGetCtl( service, &info );    // gets whether its running or not, more or less
if ( info.counterIsRunning )
    notify_post( com.apple.tcowd.ison );
else
    notify_post( com.apple.tcowd.isoff );

com.apple.ripstop.terminate:

(closes the watchdog service interface, presumably quits ripstop process)

com.apple.ripstop.debug:

(enables a debug flag, will now syslog() details when it receives notifications)

[BRSettingsHelper tellWatchdogWeAreUpAndRunning]

This function sends the 'dogy' command to the SettingsHelper tool inside the BackRow framework bundle. It essentially resets the Watchdog's failure counters in NVRAM, since the Watchdog is only interested in failures to launch the interface. Once the interface launches successfully, this function is called and the data is cleared.

The SettingsHelper performs the following tasks at this point:

  • Sets the boot count to zero.
  • Sets the maximum boot count to five.
  • Clears the system reset reason.
  • Clears the remote state.

How to Disable Watchdog

Method One: The Sedative Patch

Phoem has published source code for sedative, a patch for AppleTCOWatchdog application.

Method Two: Manually Disable Ripstop and Watchdog

First disable Ripstop. Doing this and unloading the Watchdog kext have been confirmed to work:

mkdir /etc/mach_init.disabled
mv /etc/mach_init.d/ripstop.plist /etc/mach_init.disabled

Reboot using the following command.

shutdown -r now

Ripstop is now disabled. To disable Watchdog, unload AppleTCOWatchdog.kext:

kextunload -b com.apple.driver.AppleTCOWatchdog

To unload the AppleTCOWWatchdog.kext automatically at startup. add the command to your local startup script. This is recommended as it is best to have Ripstop and Watchdog either both enabled or both disabled. In some cases the rc.local file doesn't exist. A way around it is to use su. (su is a rather dangerous command as it effectively allows you to log in as root so use it wisely!)

Copy /usr/bin/su from your local OS X installation to the same location on the AppleTV.

Then issue these commands

sudo su -
touch /etc/rc.local

Then, after you verified that rc.local exists...

echo "/sbin/kextunload -b com.apple.driver.AppleTCOWatchdog" >> /etc/rc.local

Untested Methods and Other Information

You can attempt to quit the watchdog process. Watchdog is (or at least used to be) "quit" in a special way. Locate the watchdog process and send it a 'SIGTERM' term.

From a 'man watchdog' on a Mac OS X Server:

SIGTERM
	   watchdog forces a complete shutdown when it receives the terminate
	   signal.  The automatic reboot timer will be disabled and all exe-
	   cuting children will be terminated, forcibly (with SIGKILL) if nec-
	   essary.  After all children have terminated, watchdog itself exits.
	   watchdog should always be terminated with this signal instead of
	   the kill signal (SIGKILL) to properly disable the automatic reboot

(Full output of 'man watchdog' sucked from google cache and linked at bottom of page)

Give that a try and report the results here?


Yet another failed attempt:

Auto restart is for automatically rebooting after a power failure and is present also on Mac. You can turn 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.

There's also /usr/sbin/recovery_reboot shell script, which seems to tell OS X to reboot using recovery partition (only this time). Perhaps (pretty doubtful) it is called when watchdog sniffs something bad. Easiest way to check that would be just adding something like:

echo 'oh no, I am being recovery_rebooted' > /blah

and then see if /blah exists after your ATV was rebooted by a watchdog.

How to Implement Watchdog Keepalive

The Finder contains a very simple class (called MEWatchdog) which simply installs a timer which fires every 58 seconds to call a function which does literally the following, in its entirety:

notify_post( "com.apple.riptide.heartbeat" );

This function just posts a distributed notification, so if can literally be posted by anything. Unless the Watchdog inspects the interval between notifications, it's likely that any application can perform the same test, along with the Finder, if started by something like launchd. This way, the watchdog would not reboot the machine, even if the Finder quits, and we don't have any potential side-effects arising from stopping a system process.

As an aside, 'Riptide' appears to be a codename of sorts for the AppleTV software system. Various elements within BackRow print out debug statements including file/line information, which begin with /SourceCache/Riptide-xxx/.

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.

Link to a Google cache (possibly old) output of 'man watchdog' with possibly useful information in it:

http://72.14.253.104/search?q=cache:J8bC2hERg9YJ:www.hmug.org/man/8/watchdog.html+Mac+OS+X+Server+Watchdog&hl=en&ct=clnk&cd=16&gl=us