mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-01 03:22:07 +08:00
7534abdd50
* no need to malloc one extra byte * combine two read_file into a faster one * cleanup #include * use resize * apply suggestions from review * space * rebase master old-commit-hash: fe2f63849ae467fee70c72d18fa52a184c056331
18 lines
464 B
C++
18 lines
464 B
C++
#include <string>
|
|
#include <cstdint>
|
|
#include <unistd.h>
|
|
|
|
#include "common/timing.h"
|
|
#include "common/util.h"
|
|
#include "common/watchdog.h"
|
|
|
|
const std::string watchdog_fn_prefix = "/dev/shm/wd_"; // + <pid>
|
|
|
|
bool watchdog_kick(){
|
|
std::string fn = watchdog_fn_prefix + std::to_string(getpid());
|
|
std::string cur_t = std::to_string(nanos_since_boot());
|
|
|
|
int r = util::write_file(fn.c_str(), cur_t.data(), cur_t.length(), O_WRONLY | O_CREAT);
|
|
return r == 0;
|
|
}
|