{"id":15007473,"url":"https://github.com/doubleaj/watchdog-device","last_synced_at":"2025-08-02T03:39:23.775Z","repository":{"id":62444977,"uuid":"519040663","full_name":"DoubleAJ/watchdog-device","owner":"DoubleAJ","description":"Linux Watchdog API Rust implementation.","archived":false,"fork":false,"pushed_at":"2023-12-16T02:59:13.000Z","size":53,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-26T14:51:32.899Z","etag":null,"topics":["library","linux-kernel","rust-crate","watchdog"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DoubleAJ.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-29T01:17:26.000Z","updated_at":"2025-06-04T01:42:09.000Z","dependencies_parsed_at":"2023-12-15T21:02:35.976Z","dependency_job_id":"570e0c31-0be4-4de3-affd-76ffeddb330f","html_url":"https://github.com/DoubleAJ/watchdog-device","commit_stats":{"total_commits":11,"total_committers":1,"mean_commits":11.0,"dds":0.0,"last_synced_commit":"62028e30f9a459b0e696ab55a3494af57619acf5"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/DoubleAJ/watchdog-device","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DoubleAJ%2Fwatchdog-device","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DoubleAJ%2Fwatchdog-device/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DoubleAJ%2Fwatchdog-device/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DoubleAJ%2Fwatchdog-device/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DoubleAJ","download_url":"https://codeload.github.com/DoubleAJ/watchdog-device/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DoubleAJ%2Fwatchdog-device/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268331562,"owners_count":24233285,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["library","linux-kernel","rust-crate","watchdog"],"created_at":"2024-09-24T19:10:12.947Z","updated_at":"2025-08-02T03:39:23.743Z","avatar_url":"https://github.com/DoubleAJ.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# watchdog-device\n![Build](https://github.com/DoubleAJ/watchdog-device/actions/workflows/build.yml/badge.svg) \n[![Crate](https://img.shields.io/crates/v/watchdog-device.svg)](https://crates.io/crates/watchdog-device)\n[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)\n[![API](https://docs.rs/watchdog-device/badge.svg)](https://docs.rs/watchdog-device)\n\nLinux Watchdog API Rust implementation.\n\nThis library facilitates the usage of the Watchdog driver API provided by the Linux Kernel.\nThe watchdog is used to automatically verify whether a program is running as expected. \nThe following text was readapted from the [`Linux Kernel Documentation`]:\n\nA Watchdog Timer (WDT) is a hardware circuit that can reset the computer system in case of a software fault.\nUsually a userspace daemon will notify the kernel watchdog driver that userspace is still alive, at regular intervals. \nWhen such a notification occurs, the driver will usually tell the hardware watchdog that everything is in order, \nand that the watchdog should wait for yet another little while to reset the system. \nIf userspace fails (RAM error, kernel bug, whatever), the notifications cease to occur, \nand the hardware watchdog will reset the system (causing a reboot) after the timeout occurs.\n\nIn case of the absence of a hardware watchdog, the Linux Kernel offers a software implementation via the `softdog` module.\nIt can be loaded by calling:\n```text\n# modprobe softdog\n```\n\n## Usage\nTo integrate this library to your project, add the following to your `Cargo.toml`:\n\n```toml\n[dependencies]\nwatchdog-device = \"0.2.0\"\n```\n\nA watchdog is available if any `/dev/watchdog*` file is present in the system. In order to use it, the program must be executed as a user who has read/write permissions on it.\n\nIt is possible to have more that one Watchdog. In addition to `/dev/watchdog`, there could be other files named with a numerical suffix (e.g.: `/dev/watchdog0` , `/dev/watchdog1`, etc.).\nThe function `Watchdog::new()` allows the activation of the default watchdog (represented by the file with no suffix).\nThe function `Watchdog::new_by_id()` allows the activation of a specific watchdog (represented by a file with a suffix) by indicating the numerical ID as parameter.\n\nAll drivers support the basic mode of operation, where the watchdog activates as soon as a `Watchdog` instance is created \nand will reboot unless the watchdog is pinged within a certain time, this time is called the timeout or margin. \nThe simplest way to ping the watchdog is to call the `keep_alive()` method.\n\nWhen the device is closed, the watchdog is disabled, unless the “Magic Close” feature is supported (see below). \nThis is not always such a good idea, since if there is a bug in the watchdog daemon and it crashes the system will not reboot. \nBecause of this, some of the drivers support the configuration option “Disable watchdog shutdown on close”, CONFIG_WATCHDOG_NOWAYOUT. \nIf it is set to Y when compiling the kernel, there is no way of disabling the watchdog once it has been started. \nSo, if the watchdog daemon crashes, the system will reboot after the timeout has passed. \nWatchdog devices also usually support the nowayout module parameter so that this option can be controlled at runtime.\n\n## Magic Close feature\nIf a driver supports 'Magic Close', the driver will not disable the watchdog \nunless `magic_close()` is called just before releasing the watchdog instance. \nIf the userspace daemon closes the watchdog without calling `magic_close()`, \nthe driver will assume that the daemon (and userspace in general) died, and will stop pinging the watchdog without disabling it first. \nThis will then cause a reboot if the watchdog is not re-opened in sufficient time.\n\n## Example\n\n```rust\nuse watchdog_device::Watchdog;\nuse nix::errno::Errno;\n\n\nlet mut wd = Watchdog::new()?;\nloop{\n    do_something();\n    if let Err(e) = wd.keep_alive(){\n        println!(\"Error {}\", e);\n    }\n}\n```\n\n[`Linux Kernel Documentation`]: https://www.kernel.org/doc/html/latest/watchdog/watchdog-api.html\n\n## Testing\nA series of integration tests are available. \n\nBy default `cargo test` runs tests in parallel. Since they would interfere with each other, it is important to run them one at a time:\n```bash\n$ cargo test -- --test-threads=1\n```\n\n## License\n\nThis project is [licensed under the MIT license](https://github.com/DoubleAJ/watchdog-device/blob/main/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoubleaj%2Fwatchdog-device","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoubleaj%2Fwatchdog-device","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoubleaj%2Fwatchdog-device/lists"}