How it works...

The heartbeats mechanism needs some kind of communication channel to let one component report its status to other components. In a system that is built around multiple processing units, the best choice would be network-based communication over sockets. Our application is running on a single node, and we can use one of the local IPC mechanisms instead. 

We are going to use POSIX pipes mechanisms for our heartbeat transport. When a pipe is created, it provides two file descriptors for communication—one is used to read data, while the other is used to write data.

Besides the communication transport, we need to choose the time interval for taking over. If a monitoring process does not receive a heartbeat message within this interval, ...

Get Embedded Programming with Modern C++ Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.