diff options
author | Niklas Halle <niklas@niklashalle.net> | 2020-05-21 11:49:54 +0200 |
---|---|---|
committer | Niklas Halle <niklas@niklashalle.net> | 2020-05-21 11:50:12 +0200 |
commit | e29af1f554ee40a888689e134e12f8d4a3b24ea1 (patch) | |
tree | 64c3a26f17a82fe2da03dfd27d743bc7d05bde35 /02_exercise/shell.c | |
parent | 5a200f8b131917d2e6d51df50b01042ffaafa9a6 (diff) | |
download | betriebssysteme-e29af1f554ee40a888689e134e12f8d4a3b24ea1.tar.gz betriebssysteme-e29af1f554ee40a888689e134e12f8d4a3b24ea1.zip |
cmake
Diffstat (limited to '02_exercise/shell.c')
-rw-r--r-- | 02_exercise/shell.c | 9 |
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 |