Exercise 5.4 from The Linux Programming Interface by Michael Kerrisk. The exercise is to implement dup() and dup2().