Question: 1) When you run a program from 3000shell, what does that program get for file descriptors 0, 1, and 2? Assume that you are running

1) When you run a program from 3000shell, what does that program get for file descriptors 0, 1, and 2? Assume that you are running 3000shell in a standard terminal on Linux.

2) If line 293 from 3000shell.c is removed, pid = wait(ret_status);, how will the behavior of 3000shell change?

3) How would the behaviour of 3000shell change if lines 299 and 300 were removed?

4) What does the call to setup_comm_fn() in line 167 of 3000shell.c do?

5) Are system calls used to set signal handlers? Use output from strace to show your answer is correct.

6) Does find_env() generate any system calls? Use output from strace to show your answer is correct.

7) Give the assembly code corresponding to the allocation of pattern[] on line 63. Note that this allocation may be for multiple variables. How do you know your answer is correct?

8) How can execve overwrite all of a process's memory while also preserving its file descriptors? Specifically, does preserving file descriptors require execve to avoid erasing some process memory?

9) Is the SA_RESTART flag on a signal handler (e.g., line 243) interpreted by code running in the process or in the kernel? Give evidence for your answer.

10) Implement a "listfiles" command that lists the files in the current directory. Give the code for the listfiles() function and show how you'd change the rest of the code so that typing "listfiles" runs this function. Your solution should not invoke an external executable; instead, it should do something similar to plist(). Show your changes by using diff -c.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!