Part 1 of 7 · 1 min read
Why this page comes fifth
In this module you will
- Name the common signals and their numbers, and say which can be caught and which cannot.
- Read an exit status such as 130, 137 or 139 as 128 plus a signal number.
- Write a handler that lets a program shut down cleanly on SIGTERM.
- Explain why a null-pointer access ends in SIGSEGV, and find the line with
gdb. - Enable a core dump and read it after the crash.
Pages 1 to 4 looked at programs that run, slowly or not. This page covers programs that are told to stop and programs that crash. It reuses the signals of Level 1, the page faults of Levels 6 and 7 (a bad address is a page that cannot be mapped), the process states of Level 1 and the sanitizer of Level 7. Page 6 then closes the level with the questions that interviews ask about all of this.
About this example About this example
Real: The two C programs were compiled with gcc -Wall -Wextra (crash.c also with -g -O0) and run on a Linux test machine (kernel 6.18, gdb 15). All outputs, exit statuses and the core-file size are real.
Scripted: The linked-list program with a missing end check is made up to give a short, clean crash. The message text of the graceful shutdown is made up.
Not real: The addresses in the gdb output change on every run (address randomisation, Level 10). A core file is 339,968 bytes here, and the size of one from a real program depends on its memory use.