From 7478eaee4b99abe0fcd5661f0d0adafa0dbb5013 Mon Sep 17 00:00:00 2001 From: jl4589 <jl4589@drexel.edu> Date: Tue, 4 Mar 2025 22:33:18 -0500 Subject: [PATCH] Fixed questions --- Assignment-05/questions.md | 4 ++-- Assignment-05/starter/dshlib.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Assignment-05/questions.md b/Assignment-05/questions.md index 67a2516..005398d 100644 --- a/Assignment-05/questions.md +++ b/Assignment-05/questions.md @@ -6,9 +6,9 @@ _The shell makes sure that it's all complete by calling waitpid() for each child _Closing pipes is very necessary, it will cause memory leaks, and make the pipes open causing it to read forever, and also make sure that the pipline close correctly._ -3. Your shell recognizes built-in commands (cd, exit, dragon). Unlike external commands, built-in commands do not require execvp(). Why is cd implemented as a _built-in rather than an external command? What challenges would arise if cd were implemented as an external process?_ +3. Your shell recognizes built-in commands (cd, exit, dragon). Unlike external commands, built-in commands do not require execvp(). Why is cd implemented as a built-in rather than an external command? What challenges would arise if cd were implemented as an external process? -I think cd makes it so that the shell directory itself is changed and not the original directory, it wouldn't change our shell, and would be inefficient. +_I think cd makes it so that the shell directory itself is changed and not the original directory, it wouldn't change our shell, and would be inefficient._ 4. Currently, your shell supports a fixed number of piped commands (CMD_MAX). How would you modify your implementation to allow an arbitrary number of piped commands while still handling memory allocation efficiently? What trade-offs would you need to consider? diff --git a/Assignment-05/starter/dshlib.c b/Assignment-05/starter/dshlib.c index cda615e..4df2ca0 100644 --- a/Assignment-05/starter/dshlib.c +++ b/Assignment-05/starter/dshlib.c @@ -141,7 +141,7 @@ int execute_pipeline(command_list_t *clist) { int num_commands = clist->num; int pipefd[2 * (num_commands - 1)]; pid_t pids[num_commands]; - + // for (int i = 0; i < clist->num; i++) { // printf("Command %d:\n", i); // for (int j = 0; clist->commands[i].argv[j] != NULL; j++) { -- GitLab