Name threads with pthread_setname_np so GDB shows them
Give each thread a readable name with pthread_setname_np so GDB's info threads shows it, within the 15 character limit.
Short posts that solve one thing: the code, the output we got, and why it works.
Give each thread a readable name with pthread_setname_np so GDB's info threads shows it, within the 15 character limit.
Let the kernel pick a free major number with alloc_chrdev_region on Linux 6.12, then read it back with MAJOR and find it in /proc/devices.
Split a command line into argv in place by writing NUL bytes over spaces and handling double quotes, with no allocation, for a small shell in C.
Set a breakpoint that deletes itself after the first hit with tbreak, so a one-off stop never fires again on later passes.
Set MODULE_LICENSE, MODULE_AUTHOR and MODULE_DESCRIPTION in a Linux 6.12 module, and see how the license decides which symbols you may use.
Print a usage line to stderr and exit with status 2 on a bad option, the convention used by grep, getopt and most Unix tools, in C.
Write the simplest bytecode interpreter in C, a for loop around a switch on the opcode, and see where its single indirect branch limits you.
Stop GDB the moment a variable's value changes with watch, which uses a hardware watchpoint and reports the old and new value.
Get the path of the terminal attached to a file descriptor with ttyname or the thread-safe ttyname_r, which returns NULL when it is not a terminal.
We send one email when a new post is published. No spam.