Only allocate what is necessary
Simplified handle_cmd with fork and dup2