#include "../include/exectd.h" #include #include int main(void){ FILE* in = NULL; FILE* out = NULL; char* line = NULL; size_t size = 0; const int pid = bi_popen("/bin/bash", &in, &out); if (pid < 0) { perror("bi_popen"); return 1; } fprintf(out, "pwd\n"); getline(&line, &size, in); printf("-> %s", line); fprintf(out, "date\n"); getline(&line, &size, in); printf("-> %s", line); // Since in this case we can tell the child to terminate, we'll do so // and wait for it to terminate before we close down. fprintf(out, "exit\n"); waitpid(pid, NULL, 0); fclose(in); fclose(out); free(line); return 0; }