Mehdi Akiki

Posts tagged "linux"

  • Published on

    Investigation · Part 1 of 20 · From source to a running process

    What Happens When You Run a Program: From execve to main

    My C hello world makes 32 system calls before it prints its line, the static one 14, the Rust one 61. I followed every call back to the code that made it (the kernel, the loader, libc or the Rust runtime) and I timed one start of each.
  • Published on

    Investigation · Part 8 of 10 · Following a TCP connection

    How a Name Becomes an Address: What getaddrinfo Really Does

    Connecting to localhost took 77 microseconds and connecting to 127.0.0.1 took 12, to the same server. I followed getaddrinfo with strace: four sources tried in order, files read on every call, answers sorted with IPv6 first, and a lookup that blocks the thread.
  • Published on

    Investigation · Part 7 of 10 · Following a TCP connection

    TIME_WAIT: Why a Closed Connection Stays Around

    My client and my server closed 500 connections, and the kernel kept 500 sockets for 60 more seconds. I measured which side keeps TIME_WAIT, why tcp_fin_timeout does not change it, how the client side runs out of local ports, and why a restarted server can fail to bind.
  • Published on

    Investigation · Part 6 of 10 · Following a TCP connection

    What close() Really Sends: FIN, RST and Unread Data

    close() returns 0 and the program learns nothing more. I made five small experiments to see what the other side gets: a clean end of file, a reset, a half-closed connection, a broken pipe that kills a C program, and CLOSE-WAIT sockets that never go away.
  • Published on

    Investigation · Part 5 of 10 · Following a TCP connection

    What a Full Socket Buffer Does to the Sender

    My sender wrote 2.6 MB to a peer that never read anything, and every send() said success. I looked where these bytes waited, what setsockopt really does to the buffer sizes, how a blocking sender is slowed down for free, and how an unbounded queue breaks this.