Skip to content

Instantly share code, notes, and snippets.

View twocanoes's full-sized avatar

Twocanoes Software, Inc twocanoes

View GitHub Profile
@landonf
landonf / watchdog.c
Last active October 4, 2020 17:44
Enables OS X's hardware watchdog.
#include <CoreFoundation/CoreFoundation.h>
#include <IOKit/IOKitLib.h>
#include <dispatch/dispatch.h>
// 5 minutes
#define TIMEOUT (5*60)
bool reset_watchdog (int timeout) {
io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOWatchDogTimer"));
if (service == IO_OBJECT_NULL) {