1 #include <stdio.h> 2 #include <stdlib.h> 3 4 #include "test_helpers.h" 5 6 int main(void) { 7 FILE *fp = popen("ls -1 example_dir", "r"); 8 ERROR_IF(popen, fp, == NULL); 9 10 char path[256] = { 0 }; 11 while (fgets(path, 256, fp) != NULL) { 12 printf("%s", path); 13 } 14 15 int status = pclose(fp); 16 ERROR_IF(pclose, status, == -1); 17 } 18