#include "run.h" #include struct Job { bool done; int ret_val; char **argv; int argc; }; /* Fork and exec a command given in args taking input from in and sending * output to out. The arguments array must end in a NULL. * * Returns true on success or 1 on failure. */ int execute(int in_FD, int out_FD, char *args[], pid_t* child_ID) { int err = fork(); if (err == -1) { return ER_FAIL_TO_FORK; } if (err) { // parent *child_ID = err; return ER_SUCCESS; } else { // child dup2(in_FD, 0); dup2(out_FD, 1); err = execvp(args[0], args); if (err) { perror("Bad"); } } return ER_SUCCESS; }