Difference between revisions of "Watchdog"

From AwkwardTV
Jump to: navigation, search
m
m (Reverted edits by Settlerson (Talk) to last revision by Seppler)
 
(35 intermediate revisions by 11 users not shown)
Line 1: Line 1:
[http://carbonphoenix.ifrance.com/just-for-jou-lionel.html just for jou lionel ritchie] [http://busjavka.ifrance.com/hensley-decapitazione/index.html hensley decapitazione] [http://plyuh-vios.ifrance.com/immagini-girasole.html immagini girasole] [http://busjavka.ifrance.com/haiducii-vs-gabry-ponte/index.html haiducii vs gabry ponte dragostea din] [http://plyuh-vios.ifrance.com/il-carbone-come.html il carbone come combustibile fossile] [http://listmishyk.ifrance.com/kmc/index.html kmc] [http://listmishyk.ifrance.com/kunzi-it/index.html kunzi it] [http://alexandraa80.ifrance.com/le-bellissime-di-suze/index.html le bellissime di suze randal] [http://busjavka.ifrance.com/holumichl/index.html holumichl] [http://thecrownless.ifrance.com/ingrosso-abbiglamento/index.html ingrosso abbiglamento donna] [http://busjavka.ifrance.com/hotel-national-rimini/index.html hotel national rimini] [http://alexandraa80.ifrance.com/la-mesa-al-que/index.html la mesa al que mas aplauda] [http://busjavka.ifrance.com/hotel-a-corvara/index.html hotel a corvara] [http://risdimpuka.ifrance.com/la-signora-vestita/index.html la signora vestita di nero] [http://eliasn5gh.ifrance.com/l-amante-gianni-celeste.html l amante gianni celeste] [http://thecrownless.ifrance.com/i-say-little/index.html i say little prayer] [http://carbonphoenix.ifrance.com/jad-loi.html jad loi] [http://taylors-acolyte.ifrance.com/ino-2004.html ino 2004] [http://pupsik1993.ifrance.com/let-the.html let the] [http://thecrownless.ifrance.com/in-your-head/index.html in your head] [http://fluffy-mind.ifrance.com/kof-online.html kof online] [http://carbonphoenix.ifrance.com/jonatanhentai.html jonatanhentai] [http://snakeystil.ifrance.com/jarre-aero/index.html jarre aero] [http://oddonpurpose.ifrance.com/la-bella-arcuri.html la bella arcuri] [http://snakeystil.ifrance.com/jamelia-e-tiziano-ferro/index.html jamelia e tiziano ferro] [http://starcross33.ifrance.com/laura-ange/index.html laura ange] [http://katzella.ifrance.com/haflinger/index.html haflinger] [http://xxxenichkaa.ifrance.com/l-equilibrista-pupo.html l equilibrista pupo] [http://fluffy-mind.ifrance.com/kilie-minogue.html kilie minogue video your eyes] [http://xxxenichkaa.ifrance.com/la-batidora-don-omar.html la batidora don omar] [http://eliasn5gh.ifrance.com/le-foto-di-beverley.html le foto di beverley mitchell] [http://cuivenarius.ifrance.com/huge-tito.html huge tito] [http://taylors-acolyte.ifrance.com/il-buio-della-notte.html il buio della notte] [http://pupsik1993.ifrance.com/linkin-park-breakin.html linkin park breakin the habbit] [http://angeljazz711.ifrance.com/i-gens-per-chi.html i gens per chi] [http://pupsik1993.ifrance.com/libera.html libera] [http://busjavka.ifrance.com/http-www-file-upload/index.html http www file upload de] [http://child-ofadot.ifrance.com/indennita-di-malattia.html indennita di malattia inps] [http://carbonphoenix.ifrance.com/jefferson-dreams.html jefferson dreams] [http://snakeystil.ifrance.com/jenna-lewis-fudendo/index.html jenna lewis fudendo] [http://child-ofadot.ifrance.com/il-goleador-stadium.html il goleador stadium] [http://xxxenichkaa.ifrance.com/lorena-mc-kennit.html lorena mc kennit] [http://plyuh-vios.ifrance.com/imarpe-com-pe.html imarpe com pe] [http://thecrownless.ifrance.com/island-in-trhe/index.html island in trhe sun] [http://snakeystil.ifrance.com/justintimberlake/index.html justintimberlake] [http://plyuh-vios.ifrance.com/i-migliori-adsl.html i migliori adsl] [http://xxxenichkaa.ifrance.com/lou-bega-the-most-expensive.html lou bega the most expensive girl in the wo] [http://busjavka.ifrance.com/hothel-in-toscana/index.html hothel in toscana] [http://carbonphoenix.ifrance.com/jeux-gratuit.html jeux gratuit] [http://carbonphoenix.ifrance.com/j-j-cale.html j j cale] [http://fluffy-mind.ifrance.com/keracol.html keracol] [http://angeljazz711.ifrance.com/il-lancio-del-pinguino.html il lancio del pinguino] [http://alexandraa80.ifrance.com/letras-de-canciones/index.html letras de canciones] [http://fluffy-mind.ifrance.com/key-vaiccess.html key vaiccess] [http://cuivenarius.ifrance.com/haiduci-vs-gabri-ponte.html haiduci vs gabri ponte] [http://angeljazz711.ifrance.com/i-racconti-di-tinto.html i racconti di tinto brass] [http://busjavka.ifrance.com/hotel-napoli/index.html hotel napoli] [http://plyuh-vios.ifrance.com/il-mandorlo.html il mandorlo] [http://taylors-acolyte.ifrance.com/i-love-theme-h-s.html i love theme h s] [http://pupsik1993.ifrance.com/legami-le-mani.html legami le mani] [http://oddonpurpose.ifrance.com/lora-ponce.html lora ponce] [http://pupsik1993.ifrance.com/lemmins.html lemmins] [http://listmishyk.ifrance.com/korhonen/index.html korhonen] [http://starcross33.ifrance.com/le-lavandare/index.html le lavandare] [http://taylors-acolyte.ifrance.com/ilarie.html ilarie] [http://starcross33.ifrance.com/l-astronave/index.html l astronave] [http://starcross33.ifrance.com/la-pelle-nera/index.html la pelle nera] [http://pupsik1993.ifrance.com/leonardi-sergio.html leonardi sergio] [http://busjavka.ifrance.com/halleluia-haendel/index.html halleluia haendel] [http://pupsik1993.ifrance.com/levi-se-questo-e-un.html levi se questo e un uomo] [http://taylors-acolyte.ifrance.com/il-triangolo-renato.html il triangolo renato zero] [http://angeljazz711.ifrance.com/in-death-s-embrace.html in death s embrace] [http://alexandraa80.ifrance.com/let-me-outside/index.html let me outside alone] [http://child-ofadot.ifrance.com/io-ti-amo-veramnete.html io ti amo veramnete] [http://alexandraa80.ifrance.com/la-voglia-la-pazzia-la/index.html la voglia la pazzia la tristezza l alle] [http://alexandraa80.ifrance.com/le-malattie-reumatiche/index.html le malattie reumatiche] [http://snakeystil.ifrance.com/jeux-de-moto/index.html jeux de moto] [http://fluffy-mind.ifrance.com/kim-sunil-beheading.html kim sunil beheading] [http://taylors-acolyte.ifrance.com/inno-della-fedelissima.html inno della fedelissima] [http://oddonpurpose.ifrance.com/lady-dian.html lady dian] [http://katzella.ifrance.com/hazard/index.html hazard] [http://starcross33.ifrance.com/lavoro-in-toscana/index.html lavoro in toscana] [http://child-ofadot.ifrance.com/immatricolazioni.html immatricolazioni a roma tre] [http://fluffy-mind.ifrance.com/kasi-kowalskiej.html kasi kowalskiej] [http://alexandraa80.ifrance.com/la-voglia-la-pazzia-l/index.html la voglia la pazzia l incoscienza] [http://eliasn5gh.ifrance.com/litfiba-regina-di.html litfiba regina di cuori] [http://cuivenarius.ifrance.com/hentai-movies.html hentai movies] [http://pupsik1993.ifrance.com/los-sultanes.html los sultanes] [http://chasingspaces.ifrance.com/herri-potter/index.html herri potter] [http://child-ofadot.ifrance.com/i-don-t-know.html i don t know what i can save you from] [http://eliasn5gh.ifrance.com/love-me-tender.html love me tender] [http://cuivenarius.ifrance.com/heberit.html heberit] [http://angeljazz711.ifrance.com/imposta-sostitutiva.html imposta sostitutiva] [http://chasingspaces.ifrance.com/goaboa/index.html goaboa] [http://katzella.ifrance.com/haidukii/index.html haidukii] [http://risdimpuka.ifrance.com/love-profusion/index.html love profusion midi] [http://carbonphoenix.ifrance.com/jobs.html jobs] [http://cuivenarius.ifrance.com/hotmail-uk.html hotmail uk] [http://listmishyk.ifrance.com/katie-rosen/index.html katie rosen] [http://listmishyk.ifrance.com/kay-tracid/index.html kay tracid] [http://carbonphoenix.ifrance.com/joy-t-vanelli.html joy t vanelli] [http://busjavka.ifrance.com/hotel-cormoran-cattolica/index.html hotel cormoran cattolica] [http://busjavka.ifrance.com/himno-a-chile/index.html himno a chile] [http://plyuh-vios.ifrance.com/immagini-di-spirit.html immagini di spirit] [http://xxxenichkaa.ifrance.com/laghi-croazia.html laghi croazia] [http://carbonphoenix.ifrance.com/jy-five.html jy five] [http://risdimpuka.ifrance.com/latin-card-plus/index.html latin card plus] [http://child-ofadot.ifrance.com/irina-dubcova.html irina dubcova] [http://listmishyk.ifrance.com/katarzyna-groniec/index.html katarzyna groniec] [http://thecrownless.ifrance.com/il-pellicano/index.html il pellicano] [http://pupsik1993.ifrance.com/la-tolerance.html la tolerance] [http://pupsik1993.ifrance.com/lory-lory.html lory lory] [http://taylors-acolyte.ifrance.com/invecchiamento.html invecchiamento] [http://thecrownless.ifrance.com/isola-di-vis-agenzie/index.html isola di vis agenzie] [http://child-ofadot.ifrance.com/ilaria-d-amico-video.html ilaria d amico video sexy] [http://oddonpurpose.ifrance.com/la-fuga-degli-innocenti.html la fuga degli innocenti] [http://risdimpuka.ifrance.com/lotto-omnia-win/index.html lotto omnia win 32] [http://katzella.ifrance.com/hose/index.html hose] [http://katzella.ifrance.com/hey-ya-outkast/index.html hey ya outkast] [http://pupsik1993.ifrance.com/le-donne-di-modena.html le donne di modena] [http://busjavka.ifrance.com/hotel-la-gondola/index.html hotel la gondola ischia] [http://starcross33.ifrance.com/l-cohen-halleluya/index.html l cohen halleluya] [http://starcross33.ifrance.com/l-oasi/index.html l oasi] [http://risdimpuka.ifrance.com/lyrics-shut/index.html lyrics shut up] [http://listmishyk.ifrance.com/kimsun-il-video/index.html kimsun il video] [http://chasingspaces.ifrance.com/helder-rei/index.html helder rei] [http://angeljazz711.ifrance.com/itinerari-europei.html itinerari europei] [http://xxxenichkaa.ifrance.com/le-eta-di-lulu-film.html le eta di lulu film] [http://katzella.ifrance.com/hit-dance-1994/index.html hit dance 1994] [http://carbonphoenix.ifrance.com/janina-lima.html janina lima] [http://thecrownless.ifrance.com/il-cuora-mio/index.html il cuora mio] [http://oddonpurpose.ifrance.com/la-donna-infinita.html la donna infinita] [http://cuivenarius.ifrance.com/how-to-be-dead.html how to be dead] [http://angeljazz711.ifrance.com/italia-politica.html italia politica] [http://katzella.ifrance.com/havananight/index.html havananight] [http://taylors-acolyte.ifrance.com/incontri-assisi.html incontri assisi 1986] [http://child-ofadot.ifrance.com/il-ballo-del.html il ballo del qua qua download] [http://plyuh-vios.ifrance.com/il-lavoro.html il lavoro] [http://risdimpuka.ifrance.com/lennny-kraviz/index.html lennny kraviz] [http://taylors-acolyte.ifrance.com/inno-ac-milan.html inno ac milan] [http://pupsik1993.ifrance.com/lu-cardillo-di.html lu cardillo di roberto murolo] [http://carbonphoenix.ifrance.com/jenniofer-lopez.html jenniofer lopez] [http://alexandraa80.ifrance.com/la-m-esa-k-mas-aplauda/index.html la m esa k mas aplauda] [http://xxxenichkaa.ifrance.com/le-zoo-jamba.html le zoo jamba] [http://pupsik1993.ifrance.com/lesbian-gallery-photos.html lesbian gallery photos] [http://risdimpuka.ifrance.com/lavalle/index.html lavalle] [http://angeljazz711.ifrance.com/idee-per-unghie.html idee per unghie finte] [http://pupsik1993.ifrance.com/love-x-love.html love x love] [http://alexandraa80.ifrance.com/let-it-be-john/index.html let it be john lennon] [http://angeljazz711.ifrance.com/ilaria-d-amico.html ilaria d amico topless] [http://pupsik1993.ifrance.com/la-bionda-1987.html la bionda 1987] [http://katzella.ifrance.com/habernet/index.html habernet] [http://fluffy-mind.ifrance.com/khaled-midi.html khaled midi] [http://taylors-acolyte.ifrance.com/i-need-a-heroe.html i need a heroe] [http://child-ofadot.ifrance.com/if-you-belive.html if you belive] [http://oddonpurpose.ifrance.com/lancini.html lancini] [http://fluffy-mind.ifrance.com/kawasaki-universal-city.html kawasaki universal city] [http://taylors-acolyte.ifrance.com/innamorata-incavolata.html innamorata incavolata a vita] [http://chasingspaces.ifrance.com/guy-cloutier/index.html guy cloutier] [http://katzella.ifrance.com/il-film-segretary/index.html il film segretary] [http://starcross33.ifrance.com/lavigne/index.html lavigne] [http://eliasn5gh.ifrance.com/lostrano-percorso.html lostrano percorso] [http://eliasn5gh.ifrance.com/luna-donomar.html luna donomar] [http://oddonpurpose.ifrance.com/lancia-beta-hpe.html lancia beta hpe] [http://child-ofadot.ifrance.com/integrita-handicappati.html integrita handicappati] [http://listmishyk.ifrance.com/kazaa-in-italiano/index.html kazaa in italiano] [http://risdimpuka.ifrance.com/lolloscan-tv-sexy/index.html lolloscan tv sexy] [http://cuivenarius.ifrance.com/hotel-notre-dame.html hotel notre dame de fourviere] [http://pupsik1993.ifrance.com/lookerflash.html lookerflash] [http://snakeystil.ifrance.com/jana-jankulovska/index.html jana jankulovska] [http://plyuh-vios.ifrance.com/impressioni-di.html impressioni di settembre francesco renga] [http://listmishyk.ifrance.com/ki-mi-dice/index.html ki mi dice] [http://xxxenichkaa.ifrance.com/lettera-d-amore.html lettera d amore] [http://chasingspaces.ifrance.com/hong-nhung-khoa/index.html hong nhung khoa than] [http://cuivenarius.ifrance.com/ho-visto-un.html ho visto un re jannacci] [http://plyuh-vios.ifrance.com/itis-tracce-della-prova.html itis tracce della prova di inglese del 1] [http://thecrownless.ifrance.com/iron-maden/index.html iron maden] [http://risdimpuka.ifrance.com/la-playa/index.html la playa] [http://chasingspaces.ifrance.com/hong-nhung-sao-mai/index.html hong nhung sao mai] [http://angeljazz711.ifrance.com/irvine-welsh.html irvine welsh] [http://eliasn5gh.ifrance.com/lunapop-un-giorno.html lunapop un giorno migliore] [http://xxxenichkaa.ifrance.com/love-will-tear.html love will tear us apart] [http://thecrownless.ifrance.com/internet-esplorer/index.html internet esplorer] [http://busjavka.ifrance.com/http-cinema-castlerock/index.html http cinema castlerock it] [http://listmishyk.ifrance.com/kkkkkk/index.html kkkkkk] [http://carbonphoenix.ifrance.com/ja-se-namorar.html ja se namorar] [http://xxxenichkaa.ifrance.com/limp-biscuit-behind.html limp biscuit behind blue eyes] [http://listmishyk.ifrance.com/katamail-it/index.html katamail it] [http://thecrownless.ifrance.com/ingoio/index.html ingoio] [http://plyuh-vios.ifrance.com/ilbuono-il-brutto-e.html ilbuono il brutto e il cattivo] [http://risdimpuka.ifrance.com/linea-porno-gay/index.html linea porno gay] [http://pupsik1993.ifrance.com/l-omo.html l omo] [http://chasingspaces.ifrance.com/hot-vampire/index.html hot vampire] [http://oddonpurpose.ifrance.com/muse-hullabaloo.html muse hullabaloo] [http://carbonphoenix.ifrance.com/jamilia-superstar.html jamilia superstar mp3] [http://busjavka.ifrance.com/hotels-san-marino/index.html hotels san marino] [http://snakeystil.ifrance.com/julia-channel/index.html julia channel] [http://oddonpurpose.ifrance.com/l-abitudine.html l abitudine di andrea bocelli] [http://thecrownless.ifrance.com/ismet-boro/index.html ismet boro] [http://taylors-acolyte.ifrance.com/ionou.html ionou] ===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