Pipe of Subprocess in ANSI C
Posted: Mon Dec 07, 2020 10:25 am
Hello there,
I am interested in running a pipe of subprocesses written in ANSI C using the ESP32.
The following code is just a sample I have tried to run.
And the following is the error I receive
Is then possible to do it?
I am interested in running a pipe of subprocesses written in ANSI C using the ESP32.
The following code is just a sample I have tried to run.
Code: Untitled.c Select all
int parse_output(void) {
char *cmd = "ls -l";
char buf[BUFSIZE];
FILE *fp;
if ((fp = popen(cmd, "r")) == NULL) {
printf("############## Error opening pipe!\n");
return -1;
}
while (fgets(buf, BUFSIZE, fp) != NULL) {
printf("############## OUTPUT: %s", buf);
}
if(pclose(fp)) {
printf("############## Command not found or exited with error status\n");
return -1;
}
return 0;
}
And the following is the error I receive
Code: Select all
c:\esp\../main/app_main.c:139: undefined reference to `popen`
Is then possible to do it?