Difference between revisions of "Watchdog"

From AwkwardTV
Jump to: navigation, search
m
m (Reverted edits by Settlerson (Talk) to last revision by Seppler)
 
(37 intermediate revisions by 12 users not shown)
Line 1: Line 1:
[http://libro-fantascienza.cleric4u.info libro fantascienza] [http://www-godo.firethro.info www godo] [http://lidia-troia.cleric4u.info lidia troia] [http://hdurian.airsofthost.com/view/new/basi-a.htm basi a chi mi dice] [http://patch-italiano.cleric4u.info patch italiano winmx] [http://la-sorella.firethro.info la sorella] [http://splucind.airsofthost.com/content/view/max-condizionatori/ max condizionatori] [http://splucind.airsofthost.com/content/view/wisi-y/ wisi y yandel] [http://zeroassoluto.otrev4ro.info zeroassoluto] [http://foto-cazzi.cleric4u.info foto cazzi circoncisi] [http://lejenny.airsofthost.com/library/html/pietre-artificiali.htm pietre artificiali] [http://maheinze.airsofthost.com/data/fotocamera-digitali.htm fotocamera digitali novita] [http://remayfuy.airsofthost.com/images/small/cavo-firewire/ cavo firewire 800] [http://campionato-calcio.giantlau.info campionato calcio olandese] [http://outlet-opportunita.monbrenno.info outlet opportunita di lavoro] [http://banzlees.airsofthost.com/description/lib/verwoerd-hendrik.htm verwoerd hendrik frensch] [http://www-hard.giantlau.info www hard muvi tv] [http://mercedes-.monbrenno.info mercedes 320 e] [http://splucind.airsofthost.com/content/view/portovenere/ portovenere] [http://aspazija.cleric4u.info aspazija] [http://banzlees.airsofthost.com/description/lib/comprare-solo.htm comprare solo nike shox] [http://lejenny.airsofthost.com/library/html/weuro.htm weuro] [http://bigas-luna.firethro.info bigas luna] [http://alpaddy.airsofthost.com/img/styles/riforma-protestante/ riforma protestante] [http://ann-magnuson.monbrenno.info ann magnuson] [http://hdurian.airsofthost.com/view/new/annunci-video.htm annunci video gratis] [http://vyksa.giantlau.info vyksa] [http://maheinze.airsofthost.com/data/defcon.htm defcon 4] [http://frgrossm.airsofthost.com/topic/samsung-digimax/ samsung digimax 240] [http://laortiz.airsofthost.com/view/new/pagine-bianche/ pagine bianche bergamo] [http://laortiz.airsofthost.com/view/new/canzoni-wrestling/ canzoni wrestling wwe] [http://bionda.otrev4ro.info bionda] [http://cs-cp.monbrenno.info cs cp18] [http://acer-notebook.otrev4ro.info acer notebook 3023wlmi] [http://banzlees.airsofthost.com/description/lib/gli-spogliati.htm gli spogliati] [http://hdurian.airsofthost.com/view/new/body-abbigliamento.htm body abbigliamento per neonati] [http://benassi-bros.giantlau.info benassi bros tip my heart] [http://media-center.firethro.info media center] [http://john-scofield.giantlau.info john scofield quiet] [http://sdram-mhz.giantlau.info sdram 133mhz] [http://vgt-td.firethro.info v9999gt td] [http://v-motorola.otrev4ro.info v525 motorola cellulari] [http://foto-di.firethro.info foto di julian mc mahon] [http://spot-telecom.otrev4ro.info spot telecom berlusconi] [http://frgrossm.airsofthost.com/topic/dissipatori-hd/ dissipatori hd] [http://lejenny.airsofthost.com/library/html/isocronismo.htm isocronismo] [http://lejenny.airsofthost.com/library/html/ricambi-per.htm ricambi per autoradio] [http://rumote.airsofthost.com/lib/www-comune.htm www comune bologna it] [http://laortiz.airsofthost.com/view/new/kig-kog/ kig kog] [http://battere.cleric4u.info battere] [http://hdurian.airsofthost.com/view/new/supporto-da.htm supporto da parete per tv plasma] [http://maheinze.airsofthost.com/data/da-quando.htm da quando non ci sei] [http://luce-laser.monbrenno.info luce laser] [http://alpaddy.airsofthost.com/img/styles/no-le/ no le temas a el hector y tito trebol clan] [http://splucind.airsofthost.com/content/view/foto-protagoniste/ foto protagoniste grande fratello] [http://remayfuy.airsofthost.com/images/small/the-clipper/ the clipper] [http://splucind.airsofthost.com/content/view/foto-privata/ foto privata] [http://hdurian.airsofthost.com/view/new/venezuela.htm venezuela] [http://hp-photosmart.giantlau.info hp photosmart 2710 allinone] [http://audi-pavia.cleric4u.info audi pavia] [http://banzlees.airsofthost.com/description/lib/mc-donalds.htm mc donalds] [http://professional-regulations.cleric4u.info professional regulations commission] [http://alpaddy.airsofthost.com/img/styles/www-alfa/ www alfa romeo com] [http://maheinze.airsofthost.com/data/inter.htm inter 2006] [http://maheinze.airsofthost.com/data/lk-dj.htm lk dj marky] [http://alpaddy.airsofthost.com/img/styles/sodimm-kingston/ sodimm kingston 256 mb] [http://banzlees.airsofthost.com/description/lib/www-comune.htm www comune siena it] [http://giochi-per.giantlau.info giochi per psx] [http://hdurian.airsofthost.com/view/new/telesilla.htm telesilla] [http://hp-computer.giantlau.info hp computer workstation] [http://uccisione-ostaggio.giantlau.info uccisione ostaggio iglese] [http://laortiz.airsofthost.com/view/new/mini-one/ mini one d emilia romagna] [http://maheinze.airsofthost.com/data/mezcla-latina.htm mezcla latina] [http://rumote.airsofthost.com/lib/build-a.htm build a cyber baby] [http://libero-di.monbrenno.info libero di crepare] [http://lejenny.airsofthost.com/library/html/articolo-da.htm articolo da pesca] [http://mdyankse.monbrenno.info mdyankse] [http://remayfuy.airsofthost.com/images/small/traccia-sistemi/ traccia sistemi 2004] [http://singoli-milano.giantlau.info singoli milano] [http://psicologia.cleric4u.info psicologia] [http://alpaddy.airsofthost.com/img/styles/multiculturali/ multiculturali] [http://banzlees.airsofthost.com/description/lib/gabber-mafia.htm gabber mafia] [http://remayfuy.airsofthost.com/images/small/jbl-diffusori/ jbl diffusori da pavimento] [http://ariete-elettrodomestico.firethro.info ariete elettrodomestico] [http://ferro-da.monbrenno.info ferro da stiro amstrad] [http://cantanti-sexi.otrev4ro.info cantanti sexi] [http://foto-gallery.firethro.info foto gallery amatoriali porno gratis] [http://vienna-offerta.monbrenno.info vienna offerta] [http://la-playa.giantlau.info la playa del sol] [http://eletti-in.otrev4ro.info eletti in europa] [http://rumote.airsofthost.com/lib/drunk-moms.htm drunk moms] [http://lejenny.airsofthost.com/library/html/cocaina-sesso.htm cocaina sesso] [http://alien-shooter.giantlau.info alien shooter] [http://remayfuy.airsofthost.com/images/small/altoparlanti-creative/ altoparlanti creative trigue 5 1] [http://alpaddy.airsofthost.com/img/styles/panochas-peludas/ panochas peludas] [http://alpaddy.airsofthost.com/img/styles/edius-ca/ edius ca] [http://germinazione.monbrenno.info germinazione] [http://e-le.otrev4ro.info e le stelle stanno a guardare] [http://maheinze.airsofthost.com/data/veroli.htm veroli] [http://hdurian.airsofthost.com/view/new/alessia-marcuzzi.htm alessia marcuzzi nuda integrale] [http://maheinze.airsofthost.com/data/pobre-diabla.htm pobre diabla por don omar] [http://jvc-dr.monbrenno.info jvc dr mv1se] [http://maheinze.airsofthost.com/data/villaggi-residence.htm villaggi residence sicilia] [http://frgrossm.airsofthost.com/topic/running-a/ running a cuneo] [http://remayfuy.airsofthost.com/images/small/toner/ toner 3715] [http://lejenny.airsofthost.com/library/html/etnie.htm etnie] [http://banzlees.airsofthost.com/description/lib/masterizzatori-dvd.htm masterizzatori dvd dual layer] [http://server-dedicato.monbrenno.info server dedicato linux] [http://splucind.airsofthost.com/content/view/campana-dino/ campana dino] [http://remayfuy.airsofthost.com/images/small/hp/ hp 5 2] [http://program-.giantlau.info program  6 cpr 4098 mg] [http://rumote.airsofthost.com/lib/reyna-mia.htm reyna mia] [http://cartografia-europa.otrev4ro.info cartografia europa] [http://banzlees.airsofthost.com/description/lib/www-pipoclub.htm www pipoclub com] [http://laortiz.airsofthost.com/view/new/testi-canzoni/ testi canzoni straniere] [http://laortiz.airsofthost.com/view/new/i-peni/ i peni piu lunghi del mondo] [http://alpaddy.airsofthost.com/img/styles/canon/ canon 2350] [http://lejenny.airsofthost.com/library/html/blowjob.htm blowjob] [http://hdurian.airsofthost.com/view/new/relazione-esami.htm relazione esami di licenza media] [http://lejenny.airsofthost.com/library/html/dal-nostro.htm dal nostro inviato a copenaghen] [http://frgrossm.airsofthost.com/topic/magia/ magia] [http://banzlees.airsofthost.com/description/lib/yamaha-tzr.htm yamaha tzr] [http://lejenny.airsofthost.com/library/html/dory-ghezzi.htm dory ghezzi] [http://alpaddy.airsofthost.com/img/styles/volo-economico/ volo economico caraibi] [http://doom-film.cleric4u.info doom film] [http://lejenny.airsofthost.com/library/html/comune-castelcucco.htm comune castelcucco] [http://remayfuy.airsofthost.com/images/small/alyssa-ashley/ alyssa ashley] [http://una-donna.otrev4ro.info una donna tra due mondi] [http://frgrossm.airsofthost.com/topic/kaon-ktsc/ kaon ktsc 570] [http://frgrossm.airsofthost.com/topic/incontro-per/ incontro per sesso a firenze] [http://splucind.airsofthost.com/content/view/ati-/ ati 9250 vivo] [http://stadio-aqua.cleric4u.info stadio aqua e sapone] [http://remayfuy.airsofthost.com/images/small/foto-annuncio/ foto annuncio singola] [http://shemale-big.firethro.info shemale big cock] [http://netgear-ps.monbrenno.info netgear ps121] [http://bmw-pisa.cleric4u.info bmw pisa] [http://frgrossm.airsofthost.com/topic/hp/ hp 450] [http://video-de.otrev4ro.info video de michelle vieth encuerada] [http://thomson-tv.cleric4u.info thomson tv plasma] [http://iride-hotel.monbrenno.info iride hotel] [http://scaloppine.firethro.info scaloppine] [http://rumote.airsofthost.com/lib/ariete.htm ariete 420] [http://banzlees.airsofthost.com/description/lib/miserabile-fallimento.htm miserabile fallimento] [http://frgrossm.airsofthost.com/topic/piu-ci/ piu ci penso] [http://maheinze.airsofthost.com/data/f.htm f 80] [http://scarpe-donna.otrev4ro.info scarpe donna con tacco alto] [http://banzlees.airsofthost.com/description/lib/dvd-vergini.htm dvd vergini dvdram] [http://hdurian.airsofthost.com/view/new/rex-piano.htm rex piano incasso] [http://retroescavatori.otrev4ro.info retroescavatori] [http://flash-digitale.cleric4u.info flash digitale] [http://remayfuy.airsofthost.com/images/small/tecnologie/ tecnologie] [http://hdurian.airsofthost.com/view/new/catch-and.htm catch and fish] [http://stammheim.giantlau.info stammheim] [http://lejenny.airsofthost.com/library/html/the-servant.htm the servant orchestra testo tradotto] [http://liliane.firethro.info liliane] [http://rumote.airsofthost.com/lib/singoli-bisex.htm singoli bisex superdotati] [http://worldsex-com.firethro.info worldsex com] [http://frgrossm.airsofthost.com/topic/carol-of/ carol of the bells] [http://frgrossm.airsofthost.com/topic/blu-brondi/ blu brondi cordless] [http://batteria-olympus.cleric4u.info batteria olympus li12b] [http://bomba-nucleare.cleric4u.info bomba nucleare] [http://decapitazione-ostaggio.monbrenno.info decapitazione ostaggio turco] [http://lejenny.airsofthost.com/library/html/hagen.htm hagen] [http://maheinze.airsofthost.com/data/krzysztof-krawczyk.htm krzysztof krawczyk trudno nam] [http://sound-blaster.firethro.info sound blaster live 24 bit external] [http://frgrossm.airsofthost.com/topic/milano-malpensa/ milano malpensa] [http://remayfuy.airsofthost.com/images/small/timothy/ timothy] [http://maheinze.airsofthost.com/data/pardo-y.htm pardo y aliaga felipe] [http://remayfuy.airsofthost.com/images/small/wifi-palmari/ wifi palmari] [http://rumote.airsofthost.com/lib/supporti-dvd.htm supporti dvd vergini] [http://i-racconti.firethro.info i racconti dello zio tom] [http://lavatrice-altezza.cleric4u.info lavatrice altezza 50 cm] [http://geforce-.cleric4u.info geforce 6600 gt sli schede video] [http://frgrossm.airsofthost.com/topic/www-solo/ www solo mutui it] [http://maheinze.airsofthost.com/data/software-telefonia.htm software telefonia] [http://rumote.airsofthost.com/lib/marketing-alberghiero.htm marketing alberghiero] [http://banzlees.airsofthost.com/description/lib/arkanoid-d.htm arkanoid 2d] [http://hdurian.airsofthost.com/view/new/mamen-sanz.htm mamen sanz] [http://laortiz.airsofthost.com/view/new/i-tre/ i tre della squadra speciale] [http://lejenny.airsofthost.com/library/html/sotto-il.htm sotto il sole di satana] [http://lejenny.airsofthost.com/library/html/presheva-com.htm presheva com] [http://taglia-tubi.cleric4u.info taglia tubi red] [http://ran.cleric4u.info ran] [http://tutti-tipi.otrev4ro.info tutti tipi di giochi in italiano] [http://dvd-r.otrev4ro.info dvd r vcr] [http://benq-dc.otrev4ro.info benq dc 1300] [http://palm-treo.firethro.info palm treo 650] [http://albergo-.monbrenno.info albergo 5 stella vienna] [http://polti-ferri.giantlau.info polti ferri da stiro] [http://lejenny.airsofthost.com/library/html/vedi-come.htm vedi come balla nando] [http://remayfuy.airsofthost.com/images/small/percorsi-maturita/ percorsi maturita] [http://lejenny.airsofthost.com/library/html/navigatore-satellitare.htm navigatore satellitare gps medion] [http://splucind.airsofthost.com/content/view/patente-nautica/ patente nautica in quiz] [http://toto-.firethro.info toto 47 morto] [http://www-torinoforum.monbrenno.info www torinoforum it] [http://rumote.airsofthost.com/lib/ericsson-bus.htm ericsson bus11] [http://diete-settimanali.monbrenno.info diete settimanali] [http://turner-frederick.firethro.info turner frederick jackson] [http://laortiz.airsofthost.com/view/new/iaudio-u/ iaudio u2 512 mb] [http://remayfuy.airsofthost.com/images/small/jamboo/ jamboo] ===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===
 +
 
 +
==== AppleTV 3.0.2 Method ====
 +
 
 +
Create a process to feed watchdog bones.  Source code to do this is here:  http://epplersoft.com/atv/AppleTVWatchdogFeeder.zip
 +
 
 +
==== Method One:  The Sedative Patch ====
 +
 
 +
Phoem has published [http://phoem.com/TCOWatchDog-sedative.c source code for sedative], a patch for AppleTCOWatchdog application.  '''Be Careful:  It looks like this will just corrupt the kext on the latest ATV release'''.
 +
 
 +
==== 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>
 +
 
 +
==== Apple TV 1.1 method: Use Turbo's USB and watchdog hack ====
 +
You do not need to disable ripstop, nor unload the AppleTCOWatchdog kext, just patch your /mach_kernel.prelink file as described on: [http://0xfeedbeef.com/appletv/ Turbo's AppleTV Hacks @ 0xfeedbeef.com]
 +
 
 +
==== 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]]

Latest revision as of 15:32, 30 December 2012

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

AppleTV 3.0.2 Method

Create a process to feed watchdog bones. Source code to do this is here: http://epplersoft.com/atv/AppleTVWatchdogFeeder.zip

Method One: The Sedative Patch

Phoem has published source code for sedative, a patch for AppleTCOWatchdog application. Be Careful: It looks like this will just corrupt the kext on the latest ATV release.

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

Apple TV 1.1 method: Use Turbo's USB and watchdog hack

You do not need to disable ripstop, nor unload the AppleTCOWatchdog kext, just patch your /mach_kernel.prelink file as described on: Turbo's AppleTV Hacks @ 0xfeedbeef.com

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