#include // for __IMPL #include // for fclose, FILE, pclose #include // for waitpid int pclose(FILE *stream) { int stat; fclose(stream); return (waitpid(__IMPL(stream)->pid, &stat, 0) < 0) ? -1 : stat; }