Skip to content
systemcoding.dev

Snippets

Short posts that solve one thing: the code, the output we got, and why it works.

Concurrency

Start a Tokio runtime with the

Turn async fn main into a program with the tokio::main attribute, which builds a multi-thread Tokio 1.40 runtime and runs your body on it with block_on.

1 min read
Assembly

Zero a register with xor eax, eax

Zero a register with xor eax, eax: two bytes instead of five, and the 32-bit write clears the upper half of rax too. NASM 2.16, x86-64.

1 min read
Systems Programming

Get the terminal device name with ttyname

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.

1 min read

Get new posts by email

We send one email when a new post is published. No spam.

Unsubscribe in one click. No spam, ever.