xref: /relibc/tests/stdio/popen.c (revision be35961d82cd98f2a2e61c4f1869271b9f4af571)
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