#include #include /* this shows how the popen fails to spawn "pwd" if /bin/sh is not on path */ int main() { char buff[41]; FILE* f; f = popen("pwd", "r"); if(!f) { printf("popen error\n"); return 1; } while(fgets(buff, 40, f)) printf("read: %s\n", buff); printf("pclose returned: %d\n", pclose(f)); return 0; }