Very basic dup2() system call implementation