linux_core_handler.md
1 # How To Use Breakpad As a Coredump Handler on Linux 2 3 This document presents a way to use Breakpad in order to generate 4 minidumps system wide on Linux. 5 6 Please refer to [Linux starter guide](./linux_starter_guide.md) if 7 instead you want to integrate breakpad into your application. 8 9 ## Motivation 10 11 When working on an embedded system, disk and memory space is often 12 limited and when a process crashes it must be restarted as soon as 13 possible. Sometime saving a full coredump takes to much time or 14 consumes too much space. 15 16 ## Breakpad Core Handler 17 18 In such case the program `core_handler` can be use to generate 19 minidumps instead of coredumps. `core_handler` reads the firsts 20 sections of the coredump (where the various threads are described) 21 generated by Linux from the standard input and then directly reads 22 `/proc/<pid>/mem` to reconstruct the stacktraces. 23 24 One can test it with: 25 26 ``` 27 # echo "|/usr/libexec/core_handler %P /var/lib/minidump/%e-%i.md" > 28 /proc/sys/kernel/core_pattern 29 # echo 1 > /proc/sys/kernel/core_pipe_limit 30 ``` 31 32 Be aware that a real world integration would likely require further 33 customization and so `core_handler` can be wrapped into a script (for 34 example to change the permission of the minidump file or to signal the 35 presence of the minidump to another service). 36 37 Please refer to 38 [core(5)](https://man7.org/linux/man-pages/man5/core.5.html) for more 39 details.