Application blackbox

submited by
Style Pass
2024-12-23 15:30:02

In aviation, a “black box” is the colloquial term for the flight recorder, a device that records the recent history of a flight. This device is designed to be robust to a potential crash such that the recovered data can be later used during investigation.

blackbox applies this idea to software. The principle goal of blackbox is to enable applications to save arbitrary (but structured) data during runtime and allow that data to survive any kind of crash, even SIGKILL. In addition, the blackbox can be extracted from outside the application (live or post-mortem) without introducing any blocking in the application.

Let’s first start with the API. The following is the abbreviated application-side API. The full documentation is available in blackbox.h.

In line with the idea of a flight recorder, we want to save data in the event of a crash. However, because blackbox implements this with POSIX shared memory, we want to be conservative with system resources. To that end, blackbox registers an atexit(3) handler that unlinks the shared memory. This is a clean mechanism that gives us for free the following properties:

Leave a Comment