Files
RedBear-OS/tests/stdio/popen.c
T
Tibor Nagy 4381bb2a22 tests: Remove redundant return statements
When the execution reaches the end of the main functions, they implicitly return a successful status.
2019-02-20 21:09:03 +01:00

29 lines
477 B
C

#include <stdio.h>
#include <stdlib.h>
int main(void) {
FILE *fp;
int status;
char path[256];
fp = popen("ls -1 example_dir", "r");
if (fp == NULL) {
perror("popen");
return EXIT_FAILURE;
}
while (fgets(path, 256, fp) != NULL) {
printf("%s", path);
}
status = pclose(fp);
if (status == -1) {
perror("pclose");
return EXIT_FAILURE;
} else {
printf("status %x\n", status);
}
}