Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on POSIX close(2) is broken. Parent comment
// Assume x and y are open fds and we want to replace y with a copy of x
z = open("/dev/null", O_RDONLY); // Guarantees no other thread is using z
dup2(y, z);
dup2(x, y);
close(z);
// Assume x and y are open fds and we want to replace y with a copy of x
z = open("/dev/null", O_RDONLY); // Guarantees no other thread is using z
dup2(y, z);
dup2(x, y);
close(z);