Lab 4: IPC

In this lab, you'll use labs to redirect a process's standard I/O and see how to use posix_spawn() instead of traditional UNIX process utilities. Section 3.3 of the book will be helpful.You should also consult the POSIX documentation as needed for the following functions:

  • strchr(), calloc(), free()
  • fork(), execlp(), pipe()
  • open(), close(), read(), write()
  • posix_spawn_file_actions_init(), posix_spawn_file_actions_addclose(), posix_spawn_file_actions_adddup2(), posix_spawn()

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

Your first task is to get used to the basic functionality of pipes for standard I/O redirection:

  1. Complete the implementations of split_string(), create_cksum_child(), and get_cksum() in pipe.c. Pass the INTEG_split_string, INTEG_cksum, and INTEG_child unit tests before proceeding.
  2. Complete the implementation of spawn_cksum() in pipe.c so that it behaves the same as calling get_cksum(). Instead of using fork() and exec() to run the cksum program, create the pipe and use posix_spawn().


James Madison University logo


© 2011-2024 Michael S. Kirkpatrick.
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.