Preliminaries
Set up a bare repository on stu.cs.jmu.edu based on the instructions
in the CS 361 Submission Procedures,
using the name lab4-ipc.git
.
Implementation Requirements: Pipes and Spawn
The goal for this lab is to get used to the basic functionality of pipes
for standard I/O redirection. Both of these skills are required for the
latter part of the project.
- Start at the top of
pipe.c
and build the implementation
piece by piece. First, implement create_child()
to create
a child process, redirect its output to a pipe (provided as an argument),
and execute a given program name. That is, create_child()
mostly focuses on what the child needs to do after it is created. Note
that the child must not return if exec()
fails.
- Then move on to
get_result()
to implement the parent's
portion of the work. That involves setting up the pipe and calling
create_child()
. After the child is created, make the
parent wait on the child until it finishes executing and read the
result. After completing this step and correcting the expected files,
you should be passing all unit tests and the non-spawn()
integration tests.
- Complete the implementation of
spawn_cksum()
in
pipe.c
so that it behaves the same as calling
get_result()
. Instead of using fork()
and
exec()
to run the executable program, create the
pipe and use posix_spawn()
. See the slides for documentation
on how to use functions for the posix_spawn_file_actions_t
struct.