Better handling of popen exit status