Removed submodules
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
Answer the following questions to describe your code submission. Please keep
|
||||
all lines to a maximum of 80 characters wide.
|
||||
|
||||
1 - In pseudo-code, show your general algorithm for setting up two processes
|
||||
that are connected by a pipe. You need to show all calls to relevant
|
||||
functions (e.g., pipe(), fork(), etc.) but you do not need to show error
|
||||
checking or precise syntax.
|
||||
|
||||
pipes[# of processes][2]
|
||||
for process in processes:
|
||||
pipe(pipes[process #])
|
||||
|
||||
for process in processes:
|
||||
if not first process:
|
||||
add_dup2(pipes[process #][0], stdin)
|
||||
|
||||
if not last process:
|
||||
add_dup2(pipes[process #][1], stdout)
|
||||
|
||||
for pipe in pipes:
|
||||
add_close(pipe[0])
|
||||
add_close(pipe[1])
|
||||
|
||||
if process is util:
|
||||
posix_spawn(process)
|
||||
else:
|
||||
posix_spawnp(process)
|
||||
|
||||
|
||||
2 - The project does not ask you to implement pipes with built-ins, but show
|
||||
a pseudo-code approach to modifying echo for this purpose. For simplicity,
|
||||
ignore the issues of escape characters and environment variables, and
|
||||
assume that echo only writes into the pipe. Specifically, what would be
|
||||
the flow of relevant functions (pipe(), fork(), etc.) for the following
|
||||
command line:
|
||||
|
||||
$ echo hello world | cut -f2
|
||||
|
||||
(HINT: Be careful that you do NOT close or redirect the shell's STDOUT,
|
||||
which would prevent it from displaying any more prompts!)
|
||||
|
||||
pipefd[2]
|
||||
pipe(fd)
|
||||
|
||||
echo(pipefd[1], "Message") // Modify echo to take in a file descriptor to write to
|
||||
close(pipefd[1])
|
||||
|
||||
add_dup2(pipefd[0], stdin)
|
||||
add_close(pipefd[0]);
|
||||
|
||||
posix_spawnp("cut", argv)
|
||||
|
||||
close(pipefd[0])
|
||||
|
||||
|
||||
3 - The project does not ask you to implement file redirection, but show a
|
||||
general algorithm in pseudo-code (like above) for the following command
|
||||
line (note that 2>&1 says to send STDERR to the same file as STDOUT):
|
||||
|
||||
$ ls > data.txt 2>&1
|
||||
|
||||
fd = open("data.txt")
|
||||
|
||||
add_dup2(fd, stdout)
|
||||
add_dup2(fd, stderr)
|
||||
|
||||
add_close(fd)
|
||||
|
||||
posix_spawnp("ls", argv)
|
||||
|
||||
close(fd)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user