diff --git a/Assignment-05/questions.md b/Assignment-05/questions.md index 67a25161bfa9ce32f95b75ff5ed41e50c84771e5..005398d49c9b62ea580b66d7c29eb26f92c17624 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 cda615e4041620fc409f812571fedcf6ac5ea930..4df2ca0cc52378e2b56542a16d41f1f07801db9b 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++) {