Trigger (Almost) Every Signal

Type kill -L and you’ll see all the standard signals available on Linux — 31 in total. $ kill -L 1 HUP 2 INT 3 QUIT 4 ILL 5 TRAP 6 ABRT 7 BUS 8 FPE 9 KILL 10 USR1 11 SEGV 12 USR2 13 PIPE 14 ALRM 15 TERM 16 STKFLT 17 CHLD 18 CONT 19 STOP 20 TSTP 21 TTIN 22 TTOU 23 URG 24 XCPU 25 XFSZ 26 VTALRM 27 PROF 28 WINCH 29 POLL 30 PWR 31 SYS This time, let’s try to trigger these signals in their intended scenarios....

May 23, 2025 · 21 min · 4264 words · Wokron

Linux Process Memory Management

We’ve all learned that a process’s memory consists of the heap and the stack. But this model is still too abstract — it conceals many operating system details. So here’s a brief rundown of process memory management. Heap Growth libc provides the malloc function for heap memory allocation. Under the hood, it relies on the brk system call. From the kernel’s perspective, the heap is a simple structure. It consists of a fixed heap base (the end symbol) and a movable heap top (called the program break)....

May 17, 2025 · 12 min · 2543 words · Wokron

Writing a Compile-Time Sort

Let’s have some fun with templates this time. C++ has std::integer_sequence, which lets you define compile-time integer sequences. For example: #include <utility> using my_seq = std::integer_sequence<int, 1, 2, 3, 4, 5>; Now let’s write a seq_sort_t trait that performs compile-time sorting, something like: using my_seq = std::integer_sequence<int, 2, 5, 3, 1, 4>; using sorted_my_seq = seq_sort_t<my_seq>; // std::integer_sequence<int, 1, 2, 3, 4, 5> Let’s start with some groundwork. Runtime Output Use type extraction to convert std::integer_sequence into a runtime std::initializer_list for easy output....

March 7, 2025 · 7 min · 1431 words · Wokron

Building TensorFlow from Source: Gotchas

A while back I found a small bug in TensorFlow. Now that I had some free time, I decided to submit a PR. The bug was fixed quickly, but when I tried to build TensorFlow locally, I ran into quite a few gotchas. Here are my notes. 1. So Many Versions, So Confusing Before we start building, let’s go over the relevant Nvidia GPU dependencies. Nvidia has various GPU architectures. To distinguish between them, Nvidia uses Compute Capability....

January 20, 2025 · 6 min · 1191 words · Wokron

A Discussion on Environment Variables

By “environment variables,” I mean more than just shell variables. I’m referring to the variables that each process possesses and can access through system APIs. Of course, shells typically provide ways to manipulate environment variables, and we often manage them through a shell. But shell variables and environment variables are not exactly the same thing, and the two concepts can easily be confused. Let’s try to untangle them here. 1. Environment Variables From a program’s perspective, environment variables are simple....

November 2, 2024 · 4 min · 815 words · Wokron

Installing CUDA in a Conda Environment

I’ve been wanting to learn CUDA recently. Here are my notes on setting up the environment. Create an environment. We’re just using Conda for environment isolation here — no Python needed. $ conda create -n cuda-dev $ conda activate cuda-dev Check the CUDA version with nvidia-smi. Note that this version is the maximum CUDA version supported by the driver, not the CUDA runtime version we’ll install later. When installing, make sure the CUDA runtime version ≤ the driver version....

October 14, 2024 · 1 min · 175 words · Wokron