
Wait for Child Processes with waitpid and Decode the Exit Status
Use waitpid in C on Linux to wait for a child, poll with WNOHANG, and decode the exit status with WIFEXITED, WEXITSTATUS and WTERMSIG.
Tag
362 posts

Use waitpid in C on Linux to wait for a child, poll with WNOHANG, and decode the exit status with WIFEXITED, WEXITSTATUS and WTERMSIG.

Blink the LD2 LED on a NUCLEO-F446RE by writing the GPIO registers yourself: MODER, OTYPER, OSPEEDR, PUPDR and ODR, with a SysTick delay and a register decoder.

Move sleeping work out of an interrupt handler with INIT_WORK, schedule_work and a worker function on Linux 6.12, including delayed work and safe teardown.

Learn what hexadecimal is, how each hex digit maps to four bits, and why base 16 is the standard shorthand for bytes, addresses and colours in C.

Write, compile and attach an XDP program in C that drops UDP packets for one port, with the bounds checks the verifier demands and a test you can run.

Raise the alignment of variables, structs and heap buffers with __attribute__((aligned(n))), alignas and aligned_alloc for cache lines, SIMD and DMA.

Move through a C program one line at a time in GDB with next, step, finish, until and advance, and learn which one to use when a line calls a function.

Start two ThreadX threads on an STM32 with tx_kernel_enter, tx_application_define and tx_thread_create, and learn priorities, stacks, time slices and sleep.

Run another program from C with execvp on Linux: build argv, search PATH, handle failure, and combine it with fork and waitpid to run a command safely.

Learn how push-pull and open-drain GPIO outputs differ at the transistor level, when each is right (LEDs, I2C, shared lines), and how to set both on an STM32.

Learn how binary numbers work: place values, counting, converting and why every integer in a program is a pattern of bits, with C code that prints them.

Guard a shared linked-list stack in C with pthread_mutex_lock and pthread_mutex_unlock on glibc 2.41, check return codes, and avoid leaks from missed unlocks.