Catch os.dup2 exception