The p.wait() call has been missing in the normal case, therefore no proper returncode has been returned.