Check if proc_open/fopen actually succeeded before starting to write to it.