Difference between revisions of "Watchdog"

From AwkwardTV
Jump to: navigation, search
m
Line 1: Line 1:
[http://nipierre.ifrance.com/index2_500.html index] [http://nipierre.ifrance.com/articles/lettore-divx20.htm lettore divx portatile tv tuner] [http://maramsde.ifrance.com/directory/origine-nomi/ origine nomi] [http://mejordan.ifrance.com/albergo-31.htm albergo 3 stelle copenhagen] [http://sthuckst.ifrance.com/index2_500.html map] [http://mejordan.ifrance.com/emulatori-per.htm emulatori per mame32] [http://maramsde.ifrance.com/directory/www-appendicectomia/ www appendicectomia it] [http://veredda.ifrance.com/resources/napoli-amsterdam.htm napoli amsterdam] [http://sthuckst.ifrance.com/index0_250.html page] [http://maramsde.ifrance.com/directory/syrah-planeta/ syrah planeta] [http://sthuckst.ifrance.com/btu/ btu] [http://nipierre.ifrance.com/articles/portatili-con3.htm portatili con floppy] [http://veredda.ifrance.com/resources/contrataciones-de.htm contrataciones de jugadores del equipo r] [http://bekleem.ifrance.com/index1_500.html page] [http://lokelseyn.ifrance.com/sotto-gonna/ sotto gonna] [http://trermer.ifrance.com/small/residence-sardegna/ residence sardegna capo d orso] [http://veredda.ifrance.com/resources/o-zone47.htm o zone remix] [http://lokelseyn.ifrance.com/index0_500.html link] [http://mejordan.ifrance.com/fit-one.htm fit one] [http://lokelseyn.ifrance.com/norton-utilities/ norton utilities] [http://maramsde.ifrance.com/directory/primi-dettagli2/ primi dettagli per ultimate spiderman] [http://maramsde.ifrance.com/directory/microsoft-media/ microsoft media center keyboard] [http://maramsde.ifrance.com/directory/nomi-in1/ nomi in cinese tatoo] [http://mejordan.ifrance.com/volvo-v27.htm volvo v40 t4] [http://trermer.ifrance.com/small/exilim-z1/ exilim z57] [http://sthuckst.ifrance.com/index3_250.html url] [http://trermer.ifrance.com/small/universita-onl/ universita onl line] [http://veredda.ifrance.com/resources/il-cavaliere7.htm il cavaliere nero black] [http://trermer.ifrance.com/small/bumer-original/ bumer original] [http://nipierre.ifrance.com/articles/citta-medievali.htm citta medievali 2005] [http://nipierre.ifrance.com/articles/paolo-di.htm paolo di canio] [http://veredda.ifrance.com/resources/coppie-belle.htm coppie belle] [http://nipierre.ifrance.com/articles/incontri-it.htm incontri it] [http://veredda.ifrance.com/resources/sorin-copilul3.htm sorin copilul] [http://nipierre.ifrance.com/index4_500.html homepage] [http://bekleem.ifrance.com/content/sql-interbase/ sql interbase] [http://maramsde.ifrance.com/directory/sony12/ sony 800] [http://nipierre.ifrance.com/index1_500.html link] [http://veredda.ifrance.com/index3_500.html index] [http://nipierre.ifrance.com/articles/il-pifferaio.htm il pifferaio di hamelin] [http://maramsde.ifrance.com/directory/nvidia-4/ nvidia 6800 pci] [http://lokelseyn.ifrance.com/new-line/ new line] [http://bekleem.ifrance.com/content/dalimas/ dalimas] [http://bekleem.ifrance.com/content/bootsy-bootsy/ bootsy bootsy boom] [http://veredda.ifrance.com/index3_500.html index] [http://sthuckst.ifrance.com/il-giardino9/ il giardino] [http://sthuckst.ifrance.com/index0_250.html page] [http://lokelseyn.ifrance.com/fiat-multipla9/ fiat multipla 1 9 jtd] [http://trermer.ifrance.com/index0_500.html home] [http://trermer.ifrance.com/small/hoya-filter/ hoya filter] [http://lokelseyn.ifrance.com/paracadutisti/ paracadutisti] [http://nipierre.ifrance.com/articles/verbatim-dvd4.htm verbatim dvd r 4x dl] [http://trermer.ifrance.com/index4_250.html url] [http://mejordan.ifrance.com/culo-sfondato.htm culo sfondato] [http://veredda.ifrance.com/resources/le-avventure15.htm le avventure di braccio di ferro] [http://maramsde.ifrance.com/directory/fuga-dall1/ fuga dall isola worm] [http://sthuckst.ifrance.com/bach-aria2/ bach aria sulla 4 corda] [http://maramsde.ifrance.com/directory/il-ruolo1/ il ruolo dell intellettuale nel 1600] [http://sthuckst.ifrance.com/hp-l4/ hp 4l] [http://sthuckst.ifrance.com/index4_1000.html index] [http://mejordan.ifrance.com/index2_500.html page] [http://mejordan.ifrance.com/bibbione.htm bibbione] [http://nipierre.ifrance.com/articles/gente-allegra.htm gente allegra] [http://trermer.ifrance.com/small/rs-dv2/ rs dv mmc 1 8] [http://sthuckst.ifrance.com/camargo-luciano/ camargo luciano] [http://trermer.ifrance.com/small/guarda-album/ guarda album] [http://maramsde.ifrance.com/directory/documenti-distruggi/ documenti distruggi] [http://trermer.ifrance.com/small/nokia-hsc/ nokia hs1c] [http://nipierre.ifrance.com/index1_500.html link] [http://nipierre.ifrance.com/index2_500.html index] [http://veredda.ifrance.com/resources/roma-rio1.htm roma rio janeiro] [http://trermer.ifrance.com/small/aspire-wlmi9/ aspire 1691wlmi] [http://mejordan.ifrance.com/nikon-f12.htm nikon f3] [http://nipierre.ifrance.com/articles/miss-muretto1.htm miss muretto] [http://veredda.ifrance.com/index1_250.html link] [http://mejordan.ifrance.com/jvc-videocamera1.htm jvc videocamera 24] [http://bekleem.ifrance.com/index1_500.html page] [http://bekleem.ifrance.com/content/sanyo-videoproiettori/ sanyo videoproiettori] [http://maramsde.ifrance.com/directory/modern-jazz/ modern jazz quartet] [http://veredda.ifrance.com/resources/allesandra.htm allesandra] [http://sthuckst.ifrance.com/www-gamestart/ www gamestart it] [http://maramsde.ifrance.com/directory/isnogod/ isnogod] [http://maramsde.ifrance.com/directory/af-canon/ af canon obiettivi] [http://nipierre.ifrance.com/articles/video-di40.htm video di moto] [http://sthuckst.ifrance.com/feng-shui/ feng shui] [http://sthuckst.ifrance.com/volverine/ volverine] [http://lokelseyn.ifrance.com/amd-29/ amd 64 3200 winchester socket 939] [http://sthuckst.ifrance.com/yavuz-bingol/ yavuz bingol] [http://maramsde.ifrance.com/directory/came-baby/ came baby jamiro quai] [http://mejordan.ifrance.com/paola-perego4.htm paola perego nera] [http://lokelseyn.ifrance.com/www-san1/ www san andreas it] [http://sthuckst.ifrance.com/la-spia2/ la spia che vide il suo cadavere] [http://trermer.ifrance.com/small/macchine-per5/ macchine per lamiera vicenza] [http://trermer.ifrance.com/index2_500.html homepage] [http://maramsde.ifrance.com/directory/www-unieuro/ www unieuro it] [http://sthuckst.ifrance.com/www-meteorete/ www meteorete] [http://veredda.ifrance.com/resources/le-guerre.htm le guerre puniche] [http://nipierre.ifrance.com/articles/lettore-dvd64.htm lettore dvd ram] [http://mejordan.ifrance.com/index3_1000.html homepage] [http://sthuckst.ifrance.com/index1_250.html site] [http://www.ccrs.uzh.ch/user/root/uxlirb.html Lesbiche troie] [http://www.backtothebible.org/help/files/cngtmh.html Software free isolamento termico] [http://rootos.idonea.cl/help/files/hcohpw.html Hotel camelia riccione] [http://www.notreligion.com/help/files/wnscgu.html Telecamera canon] [http://www.backtothebible.org/help/files/jepfpx.html Fax tiscali it] [http://www.ccrs.uzh.ch/user/root/puukcm.html Link www amando it oroscopo coppia html] [http://www.backtothebible.org/help/files/xgtrpv.html Testi di alanis morissette] [http://www.backtothebible.org/help/files/hedxpu.html Adware remover] [http://www.ccrs.uzh.ch/user/root/noaphp.html Francesca piccinini] [http://cale.cc/xde/it/rhhowf.html Ragazze porche video] [http://www.priceisking.co.uk/skins/default/ijsgcc.html Filmati pompini] [http://www.notreligion.com/help/files/fnboon.html Colf] [http://www.priceisking.co.uk/skins/default/hpogun.html Autocaravan] [http://www.notreligion.com/help/files/mtmtkp.html Porno toube] [http://www.actionscript.ru/help/files/gopbro.html Francesca lodo nuda] [http://rootos.idonea.cl/help/files/gimhgc.html Corsi spagnolo spagna] [http://www.priceisking.co.uk/skins/default/aemmex.html Foto gratis tettona] [http://www.priceisking.co.uk/skins/default/uivaub.html Fige depilate] [http://cale.cc/xde/it/iouhmt.html Annuncio coppia toscana] [http://www.priceisking.co.uk/skins/default/gdhjrv.html Paola pitagora nude] [http://www.actionscript.ru/help/files/habdsb.html Video negre gratis] [http://www.backtothebible.org/help/files/fbhtqw.html Sexi] [http://www.priceisking.co.uk/skins/default/dclpss.html Arctic monkeys] [http://www.notreligion.com/help/files/rnxmhq.html Hotel alicante] [http://cale.cc/xde/it/ssrgee.html Modem adsl2 ethernet] [http://www.ccrs.uzh.ch/user/root/pmhmlw.html Bed and breakfast napoli] [http://cale.cc/xde/it/cumvci.html Troie a vicenza] [http://rootos.idonea.cl/help/files/ucmvkp.html Melatonina parkinson] [http://www.ccrs.uzh.ch/user/root/ttspgj.html Belle nere] [http://www.worthwhilehosting.com/banners/auto/aqiceu.html Il ladro di orchidea] [http://cale.cc/xde/it/benjug.html Super inculate] [http://www.ccrs.uzh.ch/user/root/pxvaqj.html Federazione stati indipendenti shopping] [http://www.priceisking.co.uk/skins/default/smltal.html Karpathos] [http://www.priceisking.co.uk/skins/default/oslcju.html Immagini disney hentai] [http://www.priceisking.co.uk/skins/default/xoeeud.html Sauna gay] [http://www.nvwp.org/help/files/egdvmk.html Horse cock sucking] [http://www.worthwhilehosting.com/banners/auto/vxjcrp.html Costituzione italiana riassunto] [http://cale.cc/xde/it/eepkbp.html Teen handjob] [http://www.backtothebible.org/help/files/dvvwgv.html Musica midi] [http://www.priceisking.co.uk/skins/default/dablpb.html Fondi europei] [http://www.worthwhilehosting.com/banners/auto/mijwdl.html Radio marte] [http://www.priceisking.co.uk/skins/default/iqeoqm.html Debt relief] [http://www.worthwhilehosting.com/banners/auto/jxslon.html Fimosi] [http://www.startonlineweb.com/help/new/jbaaxn.html Esorcismi video] [http://www.hiidenkivenpaivakoti.fi/help/new/fwcoph.html Aeroporto venezia] [http://www.nvwp.org/help/files/ckuhgp.html Credito valtellinese] [http://www.ccrs.uzh.ch/user/root/jnptnj.html subasio] [http://www.ccrs.uzh.ch/user/root/hcfxkf.html Sitoesaurito tv] [http://www.startonlineweb.com/help/new/kswghf.html Afrodite night] [http://www.backtothebible.org/help/files/wurulp.html Video lesbiche gratuiti] [http://www.priceisking.co.uk/skins/default/ceiklh.html Autoscout it] [http://www.hiidenkivenpaivakoti.fi/help/new/gxfkbq.html Albergo liguria] [http://www.worthwhilehosting.com/banners/auto/mmtarb.html Centralino telefonico isdn] [http://cale.cc/xde/it/irclqp.html Elenco rivista italiane] [http://rootos.idonea.cl/help/files/qfknuh.html Pompino al cavallo] [http://www.startonlineweb.com/help/new/bkxwgi.html Solo como agriturismo] [http://cale.cc/xde/it/nhwink.html Commento delle poesia di ungaretti] [http://rootos.idonea.cl/help/files/sfftex.html Tutti testo gwen stefani] [http://www.nvwp.org/help/files/olcbfh.html Castiglione della pescaia] [http://www.startonlineweb.com/help/new/inndib.html Schedina it] [http://www.actionscript.ru/help/files/hrpkmg.html Sesto autoveicoli] [http://www.backtothebible.org/help/files/sgdbwc.html Riflessologia] [http://www.hiidenkivenpaivakoti.fi/help/new/vbhvhi.html Messaggio preziosi] [http://www.ccrs.uzh.ch/user/root/nnbwmj.html Cardgame club] [http://www.actionscript.ru/help/files/bhajvt.html Tette esagerate] [http://www.priceisking.co.uk/skins/default/qlveje.html Ultimate surrender] [http://www.actionscript.ru/help/files/bpfcio.html Free trans] [http://www.notreligion.com/help/files/megbqe.html Donne more porche] [http://www.startonlineweb.com/help/new/ouewur.html Sexysat tv it] [http://www.backtothebible.org/help/files/updatw.html Finanziamento bologna] [http://www.priceisking.co.uk/skins/default/ptxire.html Foto figa bagnata] [http://www.startonlineweb.com/help/new/fkhgov.html Pircher legname] [http://www.actionscript.ru/help/files/thidha.html Accessorio foto camera canon] [http://www.actionscript.ru/help/files/expewo.html Troie over 60] [http://www.nvwp.org/help/files/paijpm.html Shakira velo] [http://www.backtothebible.org/help/files/ahwqgn.html Classifica singoli] [http://www.notreligion.com/help/files/fguqaa.html Traduci altavista] [http://www.ccrs.uzh.ch/user/root/tanmgu.html Ferritina bassa] [http://www.backtothebible.org/help/files/xbqxdu.html Stufe a legna in maiolica] [http://www.backtothebible.org/help/files/rogpqg.html Corso autocad milano] [http://www.worthwhilehosting.com/banners/auto/ohgowg.html Hotel ascoli piceno] [http://www.worthwhilehosting.com/banners/auto/pxnpbk.html Video porno da scaricare gratis] [http://www.worthwhilehosting.com/banners/auto/rntmqv.html Agriturismo umbria] [http://www.hiidenkivenpaivakoti.fi/help/new/rpmvvr.html cassa edile napoli] [http://rootos.idonea.cl/help/files/eihcti.html Video cicciolina gratis] [http://www.notreligion.com/help/files/gtskvn.html Mermaid melody da colorare] [http://cale.cc/xde/it/lgcmpr.html Easybook] [http://www.ccrs.uzh.ch/user/root/dqpmwt.html Valentino finanza online] [http://www.nvwp.org/help/files/qpbgks.html Traduttore italiani-inglese] [http://www.backtothebible.org/help/files/gfublr.html Supermercati] [http://www.actionscript.ru/help/files/nolhls.html Kirsten dunst sex] [http://www.hiidenkivenpaivakoti.fi/help/new/spahmn.html Federvolley] [http://www.hiidenkivenpaivakoti.fi/help/new/ukhbbx.html Shemale hardcore] [http://cale.cc/xde/it/tvpuue.html Montebelluna] [http://www.priceisking.co.uk/skins/default/iriwdt.html Borsa viaggi] [http://cale.cc/xde/it/fettbq.html Campeggio sardegna] [http://www.priceisking.co.uk/skins/default/uegerr.html Veratour it] [http://www.nvwp.org/help/files/vtucbn.html Ragazze grasse nude] [http://www.nvwp.org/help/files/vpmmnv.html Federica tommasi video] [http://www.hiidenkivenpaivakoti.fi/help/new/tjcees.html Affordable health insurance] ===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 11:35, 23 September 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