summaryrefslogtreecommitdiffstats
path: root/02_exercise/shell.c
diff options
context:
space:
mode:
Diffstat (limited to '02_exercise/shell.c')
-rw-r--r--02_exercise/shell.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/02_exercise/shell.c b/02_exercise/shell.c
index f48819b..5a8d48f 100644
--- a/02_exercise/shell.c
+++ b/02_exercise/shell.c
@@ -122,17 +122,14 @@ int exec_command(const char *path, char *const argv[], unsigned timeout) {
close(pipefd[1]);
size_t length = 0;
- if ((length = read(pipefd[0], buf, 512)) <= 0) {
- fprintf(stderr, "error\n");
- exit(-3);
+ while ((length = read(pipefd[0], buf, 10)) > 0) {
+ buf[length] = '\0';
+ printf("%s", buf);
}
waitpid(pid, &status, 0);
close(pipefd[0]);
- buf[length] = '\0';
-
- printf("%s", buf);
return WEXITSTATUS(status);
} \ No newline at end of file