replace use of fclose() on a descriptor returned by popen(2) (from Carl Hetherington but manually applied)
add headers for waitpid(2)