White RoomNEW White Room DSA

Ten Thousand Defunct Workers

This accept loop has served traffic for a week. ps now shows several thousand <defunct> children, and fork() has started failing with EAGAIN.

for (;;) {
    int fd = accept(listen_fd, NULL, NULL);
    if (fd < 0) continue;

    pid_t pid = fork();
    if (pid == 0) {
        close(listen_fd);
        handle_request(fd);
        _exit(0);
    }
    close(fd);
}

Which change removes the zombies while keeping the server concurrent?